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