| Conditions | 3 | 
| Paths | 3 | 
| Total Lines | 24 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php  | 
            ||
| 21 | public function calculateWidths(int $fileSize, int $width, int $height): Collection  | 
            ||
| 22 |     { | 
            ||
| 23 | $targetWidths = collect();  | 
            ||
| 24 | |||
| 25 | $targetWidths->push($width);  | 
            ||
| 26 | |||
| 27 | $ratio = $height / $width;  | 
            ||
| 28 | $area = $height * $width;  | 
            ||
| 29 | |||
| 30 | $predictedFileSize = $fileSize;  | 
            ||
| 31 | $pixelPrice = $predictedFileSize / $area;  | 
            ||
| 32 | |||
| 33 |         while (true) { | 
            ||
| 34 | $predictedFileSize *= 0.7;  | 
            ||
| 35 | |||
| 36 | $newWidth = (int) floor(sqrt(($predictedFileSize / $pixelPrice) / $ratio));  | 
            ||
| 37 | |||
| 38 |             if ($this->finishedCalculating($predictedFileSize, $newWidth)) { | 
            ||
| 39 | return $targetWidths;  | 
            ||
| 40 | }  | 
            ||
| 41 | |||
| 42 | $targetWidths->push($newWidth);  | 
            ||
| 43 | }  | 
            ||
| 44 | }  | 
            ||
| 45 | |||
| 59 |