ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
FileMock.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Sabre\DAV;
6 
7 class FileMock implements IPatchSupport {
8 
9  protected $data = '';
10 
11  function put($str) {
12 
13  if (is_resource($str)) {
14  $str = stream_get_contents($str);
15  }
16  $this->data = $str;
17 
18  }
19 
47  function patch($data, $rangeType, $offset = null) {
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  }
72 
73  function get() {
74 
75  return $this->data;
76 
77  }
78 
79  function getContentType() {
80 
81  return 'text/plain';
82 
83  }
84 
85  function getSize() {
86 
87  return strlen($this->data);
88 
89  }
90 
91  function getETag() {
92 
93  return '"' . $this->data . '"';
94 
95  }
96 
97  function delete() {
98 
99  throw new DAV\Exception\MethodNotAllowed();
100 
101  }
102 
103  function setName($name) {
104 
105  throw new DAV\Exception\MethodNotAllowed();
106 
107  }
108 
109  function getName() {
110 
111  return 'partial';
112 
113  }
114 
115  function getLastModified() {
116 
117  return null;
118 
119  }
120 
121 
122 }
This interface provides a way to modify only part of a target resource It may be used to update a fil...
setName($name)
Renames the node.
Definition: FileMock.php:103
patch($data, $rangeType, $offset=null)
Updates the file based on a range specification.
Definition: FileMock.php:47
getSize()
Returns the size of the node, in bytes.
Definition: FileMock.php:85
getName()
Returns the name of the node.
Definition: FileMock.php:109
put($str)
Replaces the contents of the file.
Definition: FileMock.php:11
getETag()
Returns the ETag for a file.
Definition: FileMock.php:91
$this data['403_header']
getLastModified()
Returns the last modification time, as a unix timestamp.
Definition: FileMock.php:115
$data
Definition: bench.php:6
getContentType()
Returns the mime-type for a file.
Definition: FileMock.php:79