|
@@ 99-121 (lines=23) @@
|
| 96 |
|
} |
| 97 |
|
|
| 98 |
|
//TODO: refactor to have a single return type, instead of null or int |
| 99 |
|
protected function determineMaxHeight($height, $screenHeight, $screenWidth) |
| 100 |
|
{ |
| 101 |
|
if (! $screenHeight || ! $screenWidth) { |
| 102 |
|
return $height; |
| 103 |
|
} |
| 104 |
|
|
| 105 |
|
$maxHeight = $height ?: $this->image->height(); |
| 106 |
|
|
| 107 |
|
if (! $this->overrideScreenConstraint) { |
| 108 |
|
$maxHeight = $screenHeight < $maxHeight ? $screenHeight : $maxHeight; |
| 109 |
|
|
| 110 |
|
if ($this->screenConstraintMethod === 'cover') { |
| 111 |
|
$imageToScreenHeight = $screenHeight / $this->image->height(); |
| 112 |
|
$imageToScreenWidth = $screenWidth / $this->image->width(); |
| 113 |
|
|
| 114 |
|
if ($imageToScreenHeight < $imageToScreenWidth) { |
| 115 |
|
$maxHeight = null; |
| 116 |
|
} |
| 117 |
|
} |
| 118 |
|
} |
| 119 |
|
|
| 120 |
|
return $maxHeight; |
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
//TODO: refactor to have a single return type, instead of null or int |
| 124 |
|
protected function determineMaxWidth($width, $screenHeight, $screenWidth) |
|
@@ 124-145 (lines=22) @@
|
| 121 |
|
} |
| 122 |
|
|
| 123 |
|
//TODO: refactor to have a single return type, instead of null or int |
| 124 |
|
protected function determineMaxWidth($width, $screenHeight, $screenWidth) |
| 125 |
|
{ |
| 126 |
|
if (! $screenHeight || ! $screenWidth) { |
| 127 |
|
return $width; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
$maxWidth = $width ?: $this->image->width(); |
| 131 |
|
|
| 132 |
|
if (! $this->overrideScreenConstraint) { |
| 133 |
|
$maxWidth = $screenWidth < $maxWidth ? $screenWidth : $maxWidth; |
| 134 |
|
|
| 135 |
|
if ($this->screenConstraintMethod === 'cover') { |
| 136 |
|
$imageToScreenHeight = $screenHeight / $this->image->height(); |
| 137 |
|
$imageToScreenWidth = $screenWidth / $this->image->width(); |
| 138 |
|
if ($imageToScreenHeight > $imageToScreenWidth) { |
| 139 |
|
$maxWidth = null; |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
} |
| 143 |
|
|
| 144 |
|
return $maxWidth; |
| 145 |
|
} |
| 146 |
|
|
| 147 |
|
protected function determineHeight($height, $screenHeight) : int |
| 148 |
|
{ |