| Total Complexity | 7 |
| Total Lines | 70 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | class File extends FilesystemNode implements FileInterface |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * File constructor. |
||
| 16 | * |
||
| 17 | * @param array $attributes |
||
| 18 | */ |
||
| 19 | 13 | public function __construct( |
|
| 28 | 13 | } |
|
| 29 | |||
| 30 | /** |
||
| 31 | * @param string $id |
||
| 32 | * @param string $content |
||
| 33 | * @param array $attributes |
||
| 34 | * |
||
| 35 | * @throws \Exception |
||
| 36 | * |
||
| 37 | * @return \drupol\phpvfs\Node\File |
||
| 38 | */ |
||
| 39 | 12 | public static function create(string $id, string $content = '', array $attributes = []) |
|
| 40 | { |
||
| 41 | 12 | $path = Path::fromString($id); |
|
| 42 | |||
| 43 | 12 | $dirname = $path->dirname(); |
|
| 44 | |||
| 45 | 12 | $basedir = null; |
|
| 46 | 12 | if (!empty($dirname) && '.' !== $dirname) { |
|
| 47 | 11 | $basedir = Directory::create($dirname); |
|
| 48 | } |
||
| 49 | |||
| 50 | $attributes = [ |
||
| 51 | 12 | 'id' => $path->basename(), |
|
| 52 | 12 | 'content' => $content, |
|
| 53 | 12 | ] + $attributes; |
|
| 54 | |||
| 55 | 12 | $file = new self($attributes); |
|
| 56 | |||
| 57 | 12 | if (null !== $basedir) { |
|
| 58 | 11 | $basedir->add($file); |
|
| 59 | } |
||
| 60 | |||
| 61 | 12 | return $file; |
|
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | 3 | public function read(): string |
|
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @param string $data |
||
| 74 | * |
||
| 75 | * @return \drupol\phpvfs\Node\FileInterface |
||
| 76 | */ |
||
| 77 | 1 | public function write(string $data): FileInterface |
|
| 84 |