Conditions | 4 |
Paths | 4 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 13 |
CRAP Score | 4 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
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 | } |
||
85 |