1 | <?php |
||
28 | class FileNode extends File implements FileNodeInterface, FormatAwareInterface, CompressionAwareInterface, EncodingAwareInterface |
||
29 | { |
||
30 | use FormatAwareTrait; |
||
31 | use CompressionAwareTrait; |
||
32 | use EncodingAwareTrait; |
||
33 | |||
34 | /** @var FilesystemWrapperInterface */ |
||
35 | private $wrapper; |
||
36 | |||
37 | /** |
||
38 | * FileNode constructor. |
||
39 | * |
||
40 | * @param FilesystemInterface $filesystem |
||
41 | * @param null|string $path |
||
42 | */ |
||
43 | 113 | public function __construct(FilesystemInterface $filesystem, $path) |
|
44 | { |
||
45 | 113 | $this->wrapper = new FilesystemWrapper($filesystem); |
|
46 | 113 | parent::__construct($this->wrapper, $path); |
|
47 | 113 | } |
|
48 | |||
49 | /** |
||
50 | * @return string |
||
51 | */ |
||
52 | 14 | public function __toString() |
|
56 | |||
57 | /** |
||
58 | * @return mixed |
||
59 | */ |
||
60 | 10 | public function getDirectory() |
|
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | 18 | public function getFilename() |
|
72 | |||
73 | /** |
||
74 | * Returns the contents of the file as an array. |
||
75 | * |
||
76 | * @return array |
||
77 | */ |
||
78 | 21 | public function getContents() |
|
86 | |||
87 | /** |
||
88 | * @param string|null $newPath |
||
89 | * |
||
90 | * @return static |
||
91 | * @throws CopyFailedException When it is unable to copy the file |
||
92 | */ |
||
93 | 4 | public function copy($newPath = null) |
|
106 | |||
107 | /** |
||
108 | * @return FilesystemWrapperInterface |
||
109 | */ |
||
110 | 17 | public function getFilesystem() |
|
111 | { |
||
112 | 17 | return $this->wrapper; |
|
113 | } |
||
114 | |||
115 | /** |
||
116 | * @param FilesystemInterface $filesystem |
||
117 | * |
||
118 | * @return $this |
||
119 | */ |
||
120 | 1 | public function setFilesystem(FilesystemInterface $filesystem) |
|
125 | |||
126 | /** |
||
127 | * Return a clone of this object |
||
128 | * |
||
129 | * @return static |
||
130 | */ |
||
131 | 57 | public function getClone() |
|
135 | |||
136 | /** |
||
137 | * Clone sub objects |
||
138 | */ |
||
139 | 57 | public function __clone() |
|
145 | } |
||
146 |