| 1 | <?php |
||
| 11 | class Directory implements FileInterface { |
||
| 12 | |||
| 13 | private $path; |
||
| 14 | |||
| 15 | public function __construct($path = null) { |
||
| 18 | |||
| 19 | public function copyTo($destination) { |
||
| 20 | Filesystem::checkWritable($destination); |
||
| 21 | if (!file_exists($destination)) { |
||
| 22 | self::create($destination); |
||
| 23 | } |
||
| 24 | |||
| 25 | $files = glob("$this->path/*"); |
||
| 26 | foreach ($files as $file) { |
||
| 27 | $newFile = "$destination/" . basename("$file"); |
||
| 28 | if (is_dir($file)) { |
||
| 29 | self::create($newFile); |
||
| 30 | (new Directory($file))->copyTo($newFile); |
||
| 31 | } else { |
||
| 32 | copy($file, $newFile); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | public function getSize() { |
||
| 38 | |||
| 39 | } |
||
| 40 | |||
| 41 | public function moveTo($destination) { |
||
| 42 | |||
| 43 | } |
||
| 44 | |||
| 45 | public static function create($path, $permissions = 0755) { |
||
| 46 | if (file_exists($path) && !is_dir($path)) { |
||
| 47 | throw new FilesystemException("A file already exists in the location of [$path]"); |
||
| 48 | } |
||
| 49 | if (!file_exists($path)) { |
||
| 50 | mkdir($path, $permissions, true); |
||
| 51 | } |
||
| 52 | return new Directory($path); |
||
| 53 | } |
||
| 54 | |||
| 55 | public function delete() { |
||
| 58 | |||
| 59 | public function getPath() { |
||
| 62 | |||
| 63 | public function __toString() { |
||
| 66 | |||
| 67 | } |
||
| 68 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.