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