| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 29 | public function __construct( |
||
| 30 | string $filePath, |
||
| 31 | string $url |
||
| 32 | ) { |
||
| 33 | if (!file_exists($filePath)) { |
||
| 34 | throw new FileMissingException(sprintf('The file %s does not exist while constructing %s', $filePath, self::class)); |
||
| 35 | } |
||
| 36 | |||
| 37 | $this->url = $url; |
||
| 38 | |||
| 39 | if ('image/svg+xml' === mime_content_type($filePath)) { |
||
| 40 | $xmlGet = simplexml_load_string(file_get_contents($filePath)); |
||
| 41 | $xmlAttributes = $xmlGet->attributes(); |
||
| 42 | $this->width = (int) $xmlAttributes->width; |
||
| 43 | $this->height = (int) $xmlAttributes->height; |
||
| 44 | } else { |
||
| 45 | if (false === exif_imagetype($filePath)) { |
||
| 46 | throw new FileNotImageException(sprintf('The file %s is not an image while constructing %s', $filePath, self::class)); |
||
| 47 | } |
||
| 48 | |||
| 49 | [$this->width, $this->height] = getimagesize($filePath); |
||
| 50 | } |
||
| 68 |