| Total Complexity | 8 |
| Total Lines | 77 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Params |
||
| 10 | { |
||
| 11 | |||
| 12 | /** |
||
| 13 | * @var array |
||
| 14 | */ |
||
| 15 | protected $annotations; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Params constructor. |
||
| 19 | * @param array $annotations |
||
| 20 | */ |
||
| 21 | public function __construct(array $annotations) |
||
| 22 | { |
||
| 23 | $this->annotations = $annotations; |
||
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * @param string $name |
||
| 28 | * @param array $default |
||
| 29 | * @return array |
||
| 30 | */ |
||
| 31 | protected function getAttribute(string $name, array $default = []): array |
||
| 32 | { |
||
| 33 | return $this->annotations['method'][$name] ?? $default; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @param string $name |
||
| 38 | * @param int $default |
||
| 39 | * @return int |
||
| 40 | */ |
||
| 41 | protected function getInt(string $name, int $default = 0): int |
||
| 42 | { |
||
| 43 | return \current($this->getAttribute($name, [$default])); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param string $name |
||
| 48 | * @param string $default |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | protected function getString(string $name, string $default): string |
||
| 52 | { |
||
| 53 | return \current($this->getAttribute($name, [$default])); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @return int |
||
| 58 | */ |
||
| 59 | public function getWidth(): int |
||
| 60 | { |
||
| 61 | return $this->getInt('width', 1024); |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @return int |
||
| 66 | */ |
||
| 67 | public function getHeight(): int |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * @return string |
||
| 74 | */ |
||
| 75 | public function getPath(): string |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @return string |
||
| 82 | */ |
||
| 83 | public function getBrowser(): string |
||
| 89 |