| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 58 | 42 | private function getImage(string $type, string $size): string |
|
| 59 | { |
||
| 60 | 42 | $path = $type . '_path'; |
|
| 61 | 42 | if (isset($this->data->$path)) |
|
| 62 | { |
||
| 63 | 36 | if (!isset($this->conf->images->base_url)) |
|
| 64 | { |
||
| 65 | 12 | throw new \Exception('base_url configuration not found'); |
|
| 66 | } |
||
| 67 | 24 | $sizes = $type . '_sizes'; |
|
| 68 | 24 | if (!in_array($size, $this->conf->images->$sizes)) |
|
| 69 | { |
||
| 70 | 12 | throw new \Exception('Incorrect ' . $type . ' size : ' . $size); |
|
| 71 | } |
||
| 72 | 12 | return $this->conf->images->base_url . $size . $this->data->$path; |
|
| 73 | } |
||
| 74 | 6 | return ''; |
|
| 75 | } |
||
| 76 | |||
| 78 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: