| Total Complexity | 6 | 
| Total Lines | 39 | 
| Duplicated Lines | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php  | 
            ||
| 9 | class Picture  | 
            ||
| 10 | { | 
            ||
| 11 | private $path;  | 
            ||
| 12 | private $relativePath;  | 
            ||
| 13 | private $ext;  | 
            ||
| 14 | |||
| 15 | public function __construct(string $path, string $ext = null)  | 
            ||
| 16 |     { | 
            ||
| 17 | $this->path = $path;  | 
            ||
| 18 | $this->ext = $ext;  | 
            ||
| 19 | }  | 
            ||
| 20 | |||
| 21 | public function resize(string $newPath)  | 
            ||
| 22 |     { | 
            ||
| 23 | $relativePath = $newPath;  | 
            ||
| 24 | $finalNewPath = storage_path().'/'.$newPath;  | 
            ||
| 25 |         if(isset($this->ext)){ | 
            ||
| 26 | $finalNewPath = storage_path().'/'.$newPath.'.'.$this->ext;  | 
            ||
| 27 | $relativePath = $newPath.'.'.$this->ext;  | 
            ||
| 28 | }  | 
            ||
| 29 |         if(app(PictureHandler::class)->width($this->path) > 600) { | 
            ||
| 30 | app(PictureHandler::class)->widen($this->path, $finalNewPath, 600);  | 
            ||
| 31 | $this->relativePath = $relativePath;  | 
            ||
| 32 | return;  | 
            ||
| 33 | }  | 
            ||
| 34 | |||
| 35 |         if(app(PictureHandler::class)->height($this->path) > 400) { | 
            ||
| 36 | app(PictureHandler::class)->heighten($this->path, $finalNewPath, 400);  | 
            ||
| 37 | $this->relativePath = $relativePath;  | 
            ||
| 38 | return;  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 | app(PictureHandler::class)->write($this->path, $finalNewPath);  | 
            ||
| 42 | $this->relativePath = $relativePath;  | 
            ||
| 43 | }  | 
            ||
| 44 | |||
| 45 | public function relativePath(): string  | 
            ||
| 48 | }  | 
            ||
| 49 | }  | 
            ||
| 50 |