ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Filesystem\Util\PHPStreamFunctions Class Reference

Class PHPFunctions The purpose of this class is to wrap all stream handling php functions. More...

+ Collaboration diagram for ILIAS\Filesystem\Util\PHPStreamFunctions:

Static Public Member Functions

static ftell ($handle)
 ftell wrapper More...
 
static fclose ($handle)
 fclose wrapper More...
 
static fseek ($stream, $offset, $whence)
 fseek wrapper. More...
 
static fread ($handle, $length)
 fread wrapper More...
 
static stream_get_contents ($handle, $length=-1)
 stream_get_contents wrapper More...
 
static fwrite ($handle, $string, $length=null)
 fwrite wrapper More...
 

Detailed Description

Class PHPFunctions The purpose of this class is to wrap all stream handling php functions.

This allows to mock the functions within unit test which would otherwise require us to redefine the function in a scope which is scanned before the root scope and somehow call the function on our mocks the verify the function calls.

Author
Nicolas Schäfli ns@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Since
5.3
Version
1.0.0

Definition at line 16 of file PHPStreamFunctions.php.

Member Function Documentation

◆ fclose()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fclose (   $handle)
static

fclose wrapper

Parameters
$handle
See also
fclose()

Definition at line 35 of file PHPStreamFunctions.php.

Referenced by ILIAS\Filesystem\Stream\Stream\close().

36  {
37  fclose($handle);
38  }
static fclose($handle)
fclose wrapper
+ Here is the caller graph for this function:

◆ fread()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fread (   $handle,
  $length 
)
static

fread wrapper

Parameters
$handle
$length
Returns
bool|string
See also
fread()

Definition at line 59 of file PHPStreamFunctions.php.

Referenced by ILIAS\Filesystem\Stream\Stream\read().

60  {
61  return fread($handle, $length);
62  }
static fread($handle, $length)
fread wrapper
+ Here is the caller graph for this function:

◆ fseek()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fseek (   $stream,
  $offset,
  $whence 
)
static

fseek wrapper.

Parameters
$stream
$offset
$whence
Returns
int 0 or -1

Definition at line 47 of file PHPStreamFunctions.php.

Referenced by ILIAS\Filesystem\Stream\Stream\seek().

48  {
49  return fseek($stream, $offset, $whence);
50  }
static fseek($stream, $offset, $whence)
fseek wrapper.
+ Here is the caller graph for this function:

◆ ftell()

static ILIAS\Filesystem\Util\PHPStreamFunctions::ftell (   $handle)
static

ftell wrapper

Parameters
$handle
Returns
bool|int
See also
ftell()

Definition at line 25 of file PHPStreamFunctions.php.

Referenced by ILIAS\Filesystem\Stream\Stream\tell().

26  {
27  return ftell($handle);
28  }
+ Here is the caller graph for this function:

◆ fwrite()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fwrite (   $handle,
  $string,
  $length = null 
)
static

fwrite wrapper

Parameters
$handle
$string
null$length
Returns
bool|int
See also
fwrite()

Definition at line 84 of file PHPStreamFunctions.php.

Referenced by ILIAS\Filesystem\Stream\StreamTest\testWriteWhichShouldSucceed(), and ILIAS\Filesystem\Stream\Stream\write().

85  {
86 
87  //it seems like php juggles the null to 0 and pass it to the function which leads to a write operation of zero length ...
88  if (is_null($length)) {
89  return fwrite($handle, $string);
90  }
91 
92  return fwrite($handle, $string, $length);
93  }
static fwrite($handle, $string, $length=null)
fwrite wrapper
+ Here is the caller graph for this function:

◆ stream_get_contents()

static ILIAS\Filesystem\Util\PHPStreamFunctions::stream_get_contents (   $handle,
  $length = -1 
)
static

stream_get_contents wrapper

Parameters
$handle
$length
Returns
bool|string
See also
stream_get_contents()

Definition at line 71 of file PHPStreamFunctions.php.

Referenced by ILIAS\Filesystem\Stream\Stream\getContents().

72  {
73  return stream_get_contents($handle, $length);
74  }
static stream_get_contents($handle, $length=-1)
stream_get_contents wrapper
+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: