Code Duplication    Length = 22-23 lines in 2 locations

src/Image.php 2 locations

@@ 85-107 (lines=23) @@
82
    }
83
84
    //TODO: refactor to have a single return type, instead of null or int
85
    protected function determineMaxHeight($height, $screenHeight, $screenWidth)
86
    {
87
        if (! $screenHeight || ! $screenWidth) {
88
            return $height;
89
        }
90
91
        $maxHeight = $height ?: $this->image->height();
92
93
        if (! $this->overrideScreenConstraint) {
94
            $maxHeight = $screenHeight < $maxHeight ? $screenHeight : $maxHeight;
95
96
            if ($this->screenConstraintMethod === 'cover') {
97
                $imageToScreenHeight = $screenHeight / $this->image->height();
98
                $imageToScreenWidth = $screenWidth / $this->image->width();
99
100
                if ($imageToScreenHeight < $imageToScreenWidth) {
101
                    $maxHeight = null;
102
                }
103
            }
104
        }
105
106
        return $maxHeight;
107
    }
108
109
    //TODO: refactor to have a single return type, instead of null or int
110
    protected function determineMaxWidth($width, $screenHeight, $screenWidth)
@@ 110-131 (lines=22) @@
107
    }
108
109
    //TODO: refactor to have a single return type, instead of null or int
110
    protected function determineMaxWidth($width, $screenHeight, $screenWidth)
111
    {
112
        if (! $screenHeight || ! $screenWidth) {
113
            return $width;
114
        }
115
116
        $maxWidth = $width ?: $this->image->width();
117
118
        if (! $this->overrideScreenConstraint) {
119
            $maxWidth = $screenWidth < $maxWidth ? $screenWidth : $maxWidth;
120
121
            if ($this->screenConstraintMethod === 'cover') {
122
                $imageToScreenHeight = $screenHeight / $this->image->height();
123
                $imageToScreenWidth = $screenWidth / $this->image->width();
124
                if ($imageToScreenHeight > $imageToScreenWidth) {
125
                    $maxWidth = null;
126
                }
127
            }
128
        }
129
130
        return $maxWidth;
131
    }
132
133
    protected function determineHeight($height, $screenHeight) : int
134
    {