Conditions | 6 |
Paths | 9 |
Total Lines | 25 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
36 | public static function interpretFont(string $name, $data, PathResolver $pathResolver): Font |
||
37 | { |
||
38 | if (is_string($data)) { |
||
39 | /* Font defined as |
||
40 | * Arial: /usr/share/fonts/truetype/Arial.ttf |
||
41 | */ |
||
42 | $isBold = false; |
||
43 | $isItalic = false; |
||
44 | $location = $data; |
||
45 | } elseif (is_array($data)) { |
||
46 | /* Font defined as |
||
47 | * Arial: |
||
48 | * - location: /usr/share/fonts/truetype/ArialBoldItalic.ttf |
||
49 | * - bold: false |
||
50 | * - italic: false |
||
51 | */ |
||
52 | $isBold = (isset($data['bold'])) ? (bool) $data['bold'] : false; |
||
53 | $isItalic = (isset($data['italic'])) ? (bool) $data['italic'] : false; |
||
54 | $location = (isset($data['location'])) ? (string) $data['location'] : ''; |
||
55 | } else { |
||
56 | throw new \InvalidArgumentException("Cannot interpret fonts as one of them is not a string or an array"); |
||
57 | } |
||
58 | $location = $pathResolver->obtainPath($location); |
||
59 | |||
60 | return new Font($name, $isBold, $isItalic, $location); |
||
61 | } |
||
68 |