Code Duplication    Length = 9-10 lines in 2 locations

src/CImage/CImage.php 2 locations

@@ 1758-1766 (lines=9) @@
1755
1756
1757
        // Only use a specified area of the image, $this->offset is defining the area to use
1758
        if (isset($this->offset)) {
1759
            $this->log("Offset for area to use, cropping it width={$this->offset['width']}, height={$this->offset['height']}, start_x={$this->offset['left']}, start_y={$this->offset['top']}");
1760
            $img = $this->CreateImageKeepTransparency($this->offset['width'], $this->offset['height']);
1761
            imagecopy($img, $this->image, 0, 0, $this->offset['left'], $this->offset['top'], $this->offset['width'], $this->offset['height']);
1762
            $this->image = $img;
1763
            $this->width = $this->offset['width'];
1764
            $this->height = $this->offset['height'];
1765
        }
1766
1767
        if ($this->crop) {
1768
            // Do as crop, take only part of image
1769
            $this->log("Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}");
@@ 1767-1776 (lines=10) @@
1764
            $this->height = $this->offset['height'];
1765
        }
1766
1767
        if ($this->crop) {
1768
            // Do as crop, take only part of image
1769
            $this->log("Cropping area width={$this->crop['width']}, height={$this->crop['height']}, start_x={$this->crop['start_x']}, start_y={$this->crop['start_y']}");
1770
            $img = $this->CreateImageKeepTransparency($this->crop['width'], $this->crop['height']);
1771
            imagecopy($img, $this->image, 0, 0, $this->crop['start_x'], $this->crop['start_y'], $this->crop['width'], $this->crop['height']);
1772
            $this->image = $img;
1773
            $this->width = $this->crop['width'];
1774
            $this->height = $this->crop['height'];
1775
        }
1776
1777
        if (!$this->upscale) {
1778
            // Consider rewriting the no-upscale code to fit within this if-statement,
1779
            // likely to be more readable code.