Conditions | 3 |
Paths | 2 |
Total Lines | 19 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
25 | 9 | public static function fromArray(array $attributes): self |
|
26 | { |
||
27 | 9 | if (array_key_exists('orientation', $attributes) |
|
28 | 9 | && !in_array($attributes['orientation'], ['portrait', 'landscape']) |
|
29 | ) { |
||
30 | 1 | throw new \InvalidArgumentException( |
|
31 | 1 | sprintf( |
|
32 | 'Mode should either be "portrait" or "landscape", got "%s"', |
||
33 | 1 | $attributes['orientation'] |
|
34 | ) |
||
35 | ); |
||
36 | } |
||
37 | |||
38 | 8 | return new self( |
|
39 | 8 | filename: $attributes['filename'], |
|
40 | 8 | html: $attributes['html'], |
|
41 | 8 | orientation: $attributes['orientation'] ?? 'portrait', |
|
42 | 8 | options: $attributes['options'] ?? [], |
|
43 | 8 | path: $attributes['path'] ?? '/', |
|
44 | ); |
||
47 |