ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Filesystem\Util\PHPStreamFunctions Class Reference

Class PHPFunctions. More...

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

Static Public Member Functions

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

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 34 of file PHPStreamFunctions.php.

Member Function Documentation

◆ fclose()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fclose (   $handle)
static
Parameters
resource$handle
See also
fclose()

Definition at line 63 of file PHPStreamFunctions.php.

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

63  : void
64  {
65  fclose($handle);
66  }
+ Here is the caller graph for this function:

◆ fread()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fread (   $handle,
int  $length 
)
static
Parameters
resource$handle
Returns
bool|string
See also
fread()

Definition at line 73 of file PHPStreamFunctions.php.

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

74  {
75  return fread($handle, $length);
76  }
+ Here is the caller graph for this function:

◆ fseek()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fseek (   $stream,
int  $offset,
int  $whence 
)
static
Parameters
resource$stream
Returns
int 0 or -1

Definition at line 54 of file PHPStreamFunctions.php.

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

54  : int
55  {
56  return fseek($stream, $offset, $whence);
57  }
static fseek($stream, int $offset, int $whence)
+ Here is the caller graph for this function:

◆ ftell()

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

ftell wrapper

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

Definition at line 45 of file PHPStreamFunctions.php.

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

46  {
47  return ftell($handle);
48  }
+ Here is the caller graph for this function:

◆ fwrite()

static ILIAS\Filesystem\Util\PHPStreamFunctions::fwrite (   $handle,
string  $string,
?int  $length = null 
)
static
Parameters
resource$handle
Returns
bool|int
See also
fwrite()

Definition at line 94 of file PHPStreamFunctions.php.

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

95  {
96  if (is_null($length)) {
97  return fwrite($handle, $string);
98  }
99 
100  return fwrite($handle, $string, $length);
101  }
static fwrite($handle, string $string, ?int $length=null)
+ Here is the caller graph for this function:

◆ stream_get_contents()

static ILIAS\Filesystem\Util\PHPStreamFunctions::stream_get_contents (   $handle,
  $length = -1 
)
static
Parameters
resource$handle
Returns
bool|string
See also
stream_get_contents()

Definition at line 83 of file PHPStreamFunctions.php.

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

84  {
85  return stream_get_contents($handle, $length);
86  }
static stream_get_contents($handle, $length=-1)
+ Here is the caller graph for this function:

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