|
18 | 18 | */ |
19 | 19 | abstract class Image |
20 | 20 | { |
21 | | - /** |
22 | | - * @var array $attributes Key / value store to be used for meta information by delegates. |
23 | | - */ |
24 | | - protected $attributes = array(); |
| 21 | + /** |
| 22 | + * @var array $attributes Key / value store to be used for meta information by delegates. |
| 23 | + */ |
| 24 | + protected array $attributes = []; |
25 | 25 |
|
26 | | - /** |
27 | | - * C'tor |
28 | | - * |
29 | | - * @param array $classNames List of Delegate inheriting classes providing transformations. |
30 | | - */ |
31 | | - public function __construct($filepath = false) |
32 | | - { |
33 | | - $this->initialize(); |
34 | | - |
35 | | - if(false !== $filepath) |
| 26 | + /** |
| 27 | + * @param bool $filepath |
| 28 | + */ |
| 29 | + public function __construct($filepath = false) |
36 | 30 | { |
37 | | - $this->open($filepath); |
| 31 | + $this->initialize(); |
| 32 | + |
| 33 | + if (false !== $filepath) { |
| 34 | + $this->open($filepath); |
| 35 | + } |
38 | 36 | } |
39 | | - } |
40 | 37 |
|
41 | | - /** |
42 | | - * Initializes image-api specific code |
43 | | - */ |
44 | | - abstract protected function initialize(); |
| 38 | + /** |
| 39 | + * Initializes image-api specific code |
| 40 | + */ |
| 41 | + abstract protected function initialize(); |
45 | 42 |
|
46 | | - /** |
47 | | - * Attribute accessor. |
48 | | - * |
49 | | - * @param string $key Name of the attribute to return |
50 | | - * @param array $default Default value in case the key is unknown |
51 | | - * @return mixed The value as stored in $this->attributes[$key] or the $default |
52 | | - */ |
53 | | - public function get($key, $default = false) |
54 | | - { |
55 | | - return array_key_exists($key, $this->attributes) ? $this->attributes[$key] : $default; |
56 | | - } |
| 43 | + /** |
| 44 | + * Attribute accessor. |
| 45 | + * |
| 46 | + * @param string $key Name of the attribute to return |
| 47 | + * @param bool|array $default Default value in case the key is unknown |
| 48 | + * @return mixed The value as stored in $this->attributes[$key] or the $default |
| 49 | + */ |
| 50 | + public function get(string $key, bool|array $default = false): mixed |
| 51 | + { |
| 52 | + return array_key_exists($key, $this->attributes) ? $this->attributes[$key] : $default; |
| 53 | + } |
57 | 54 |
|
58 | | - /** |
59 | | - * Attribute mutator. |
60 | | - w |
61 | | - * |
62 | | - * @param string $key Name of the attribute to set |
63 | | - * @param array $value Value to be set |
64 | | - */ |
65 | | - public function set($key, $value) |
66 | | - { |
67 | | - $this->attributes[$key] = $value; |
68 | | - } |
| 55 | + /** |
| 56 | + * Attribute mutator. |
| 57 | + * w |
| 58 | + * |
| 59 | + * @param string $key Name of the attribute to set |
| 60 | + * @param array $value Value to be set |
| 61 | + */ |
| 62 | + public function set($key, $value): void |
| 63 | + { |
| 64 | + $this->attributes[$key] = $value; |
| 65 | + } |
69 | 66 | } |
0 commit comments