Total Complexity | 7 |
Total Lines | 71 |
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 | 19 | public function __construct( |
|
28 | 19 | } |
|
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 | 17 | public static function create(string $id, string $content = '', array $attributes = []) |
|
40 | { |
||
41 | 17 | $path = Path::fromString($id); |
|
42 | |||
43 | 17 | $dirname = $path->dirname(); |
|
44 | |||
45 | 17 | $basedir = null; |
|
46 | |||
47 | 17 | if ('' !== $dirname && '.' !== $dirname) { |
|
48 | 15 | $basedir = Directory::create($dirname); |
|
49 | } |
||
50 | |||
51 | $attributes = [ |
||
52 | 17 | 'id' => $path->basename(), |
|
53 | 17 | 'content' => $content, |
|
54 | 17 | ] + $attributes; |
|
55 | |||
56 | 17 | $file = new self($attributes); |
|
57 | |||
58 | 17 | if (null !== $basedir) { |
|
59 | 15 | $basedir->add($file); |
|
60 | } |
||
61 | |||
62 | 17 | return $file; |
|
63 | } |
||
64 | |||
65 | /** |
||
66 | * @return string |
||
67 | */ |
||
68 | 3 | public function read(): string |
|
71 | } |
||
72 | |||
73 | /** |
||
74 | * @param string $data |
||
75 | * |
||
76 | * @return \drupol\phpvfs\Node\FileInterface |
||
77 | */ |
||
78 | 1 | public function write(string $data): FileInterface |
|
85 |