| Conditions | 4 |
| Paths | 3 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 36 | public function resize(Image $image, int $maxHeight): string |
||
| 37 | { |
||
| 38 | if ($image->getHeight() <= $maxHeight || $image->getMime() === 'image/svg+xml') { |
||
| 39 | return $image->getPath(); |
||
| 40 | } |
||
| 41 | |||
| 42 | $basename = pathinfo($image->getFilename(), PATHINFO_FILENAME); |
||
| 43 | $path = realpath('.') . '/' . self::CACHE_IMAGE_PATH . $basename . '-' . $maxHeight . '.jpg'; |
||
| 44 | |||
| 45 | if (file_exists($path)) { |
||
| 46 | return $path; |
||
| 47 | } |
||
| 48 | |||
| 49 | $image = $this->imagine->open($image->getPath()); |
||
| 50 | $image->thumbnail(new Box(1000000, $maxHeight))->save($path); |
||
| 51 | |||
| 52 | return $path; |
||
| 53 | } |
||
| 55 |