ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\PartialUpdate\FileMock Class Reference
+ Inheritance diagram for Sabre\DAV\PartialUpdate\FileMock:
+ Collaboration diagram for Sabre\DAV\PartialUpdate\FileMock:

Public Member Functions

 put ($str)
 Replaces the contents of the file. More...
 
 patch ($data, $rangeType, $offset=null)
 Updates the file based on a range specification. More...
 
 get ()
 Returns the data. More...
 
 getContentType ()
 Returns the mime-type for a file. More...
 
 getSize ()
 Returns the size of the node, in bytes. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 delete ()
 Deleted the current node. More...
 
 setName ($name)
 Renames the node. More...
 
 getName ()
 Returns the name of the node. More...
 
 getLastModified ()
 Returns the last modification time, as a unix timestamp. More...
 

Protected Attributes

 $data = ''
 

Detailed Description

Definition at line 7 of file FileMock.php.

Member Function Documentation

◆ delete()

Sabre\DAV\PartialUpdate\FileMock::delete ( )

Deleted the current node.

Returns
void

Implements Sabre\DAV\INode.

Definition at line 97 of file FileMock.php.

97  {
98 
99  throw new DAV\Exception\MethodNotAllowed();
100 
101  }

◆ get()

Sabre\DAV\PartialUpdate\FileMock::get ( )

Returns the data.

This method may either return a string or a readable stream resource

Returns
mixed

Implements Sabre\DAV\IFile.

Definition at line 73 of file FileMock.php.

References $data.

73  {
74 
75  return $this->data;
76 
77  }
$data
Definition: bench.php:6

◆ getContentType()

Sabre\DAV\PartialUpdate\FileMock::getContentType ( )

Returns the mime-type for a file.

If null is returned, we'll assume application/octet-stream

Returns
string|null

Implements Sabre\DAV\IFile.

Definition at line 79 of file FileMock.php.

79  {
80 
81  return 'text/plain';
82 
83  }

◆ getETag()

Sabre\DAV\PartialUpdate\FileMock::getETag ( )

Returns the ETag for a file.

An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.

Return null if the ETag can not effectively be determined.

The ETag must be surrounded by double-quotes, so something like this would make a valid ETag:

return '"someetag"';

Returns
string|null

Implements Sabre\DAV\IFile.

Definition at line 91 of file FileMock.php.

References data.

91  {
92 
93  return '"' . $this->data . '"';
94 
95  }
$this data['403_header']

◆ getLastModified()

Sabre\DAV\PartialUpdate\FileMock::getLastModified ( )

Returns the last modification time, as a unix timestamp.

Return null if the information is not available.

Returns
int|null

Implements Sabre\DAV\INode.

Definition at line 115 of file FileMock.php.

115  {
116 
117  return null;
118 
119  }

◆ getName()

Sabre\DAV\PartialUpdate\FileMock::getName ( )

Returns the name of the node.

This is used to generate the url.

Returns
string

Implements Sabre\DAV\INode.

Definition at line 109 of file FileMock.php.

109  {
110 
111  return 'partial';
112 
113  }

◆ getSize()

Sabre\DAV\PartialUpdate\FileMock::getSize ( )

Returns the size of the node, in bytes.

Returns
int

Implements Sabre\DAV\IFile.

Definition at line 85 of file FileMock.php.

References data.

85  {
86 
87  return strlen($this->data);
88 
89  }
$this data['403_header']

◆ patch()

Sabre\DAV\PartialUpdate\FileMock::patch (   $data,
  $rangeType,
  $offset = null 
)

Updates the file based on a range specification.

The first argument is the data, which is either a readable stream resource or a string.

The second argument is the type of update we're doing. This is either:

  • 1. append
  • 2. update based on a start byte
  • 3. update based on an end byte ; The third argument is the start or end byte.

After a successful put operation, you may choose to return an ETag. The etag must always be surrounded by double-quotes. These quotes must appear in the actual string you're returning.

Clients may use the ETag from a PUT request to later on make sure that when they update the file, the contents haven't changed in the mean time.

Parameters
resource | string$data
int$rangeType
int$offset
Returns
string|null

Implements Sabre\DAV\PartialUpdate\IPatchSupport.

Definition at line 47 of file FileMock.php.

References $data, and data.

47  {
48 
49  if (is_resource($data)) {
50  $data = stream_get_contents($data);
51  }
52 
53  switch ($rangeType) {
54 
55  case 1 :
56  $this->data .= $data;
57  break;
58  case 3 :
59  // Turn the offset into an offset-offset.
60  $offset = strlen($this->data) - $offset;
61  // No break is intentional
62  case 2 :
63  $this->data =
64  substr($this->data, 0, $offset) .
65  $data .
66  substr($this->data, $offset + strlen($data));
67  break;
68 
69  }
70 
71  }
$this data['403_header']
$data
Definition: bench.php:6

◆ put()

Sabre\DAV\PartialUpdate\FileMock::put (   $data)

Replaces the contents of the file.

The data argument is a readable stream resource.

After a successful put operation, you may choose to return an ETag. The etag must always be surrounded by double-quotes. These quotes must appear in the actual string you're returning.

Clients may use the ETag from a PUT request to later on make sure that when they update the file, the contents haven't changed in the mean time.

If you don't plan to store the file byte-by-byte, and you return a different object on a subsequent GET you are strongly recommended to not return an ETag, and just return null.

Parameters
resource | string$data
Returns
string|null

Implements Sabre\DAV\IFile.

Definition at line 11 of file FileMock.php.

References data.

11  {
12 
13  if (is_resource($str)) {
14  $str = stream_get_contents($str);
15  }
16  $this->data = $str;
17 
18  }
$this data['403_header']

◆ setName()

Sabre\DAV\PartialUpdate\FileMock::setName (   $name)

Renames the node.

Parameters
string$nameThe new name
Returns
void

Implements Sabre\DAV\INode.

Definition at line 103 of file FileMock.php.

103  {
104 
105  throw new DAV\Exception\MethodNotAllowed();
106 
107  }

Field Documentation

◆ $data

Sabre\DAV\PartialUpdate\FileMock::$data = ''
protected

Definition at line 9 of file FileMock.php.


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