Code Duplication    Length = 18-18 lines in 2 locations

lib/Cpdf.php 2 locations

@@ 2993-3010 (lines=18) @@
2990
     * @param $color
2991
     * @param bool $force
2992
     */
2993
    function setColor($color, $force = false)
2994
    {
2995
        $new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
2996
2997
        if (!$force && $this->currentColor == $new_color) {
2998
            return;
2999
        }
3000
3001
        if (isset($new_color[3])) {
3002
            $this->currentColor = $new_color;
3003
            $this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F k", $this->currentColor));
3004
        } else {
3005
            if (isset($new_color[2])) {
3006
                $this->currentColor = $new_color;
3007
                $this->addContent(vsprintf("\n%.3F %.3F %.3F rg", $this->currentColor));
3008
            }
3009
        }
3010
    }
3011
3012
    /**
3013
     * sets the color for fill operations
@@ 3032-3049 (lines=18) @@
3029
     * @param $color
3030
     * @param bool $force
3031
     */
3032
    function setStrokeColor($color, $force = false)
3033
    {
3034
        $new_color = array($color[0], $color[1], $color[2], isset($color[3]) ? $color[3] : null);
3035
3036
        if (!$force && $this->currentStrokeColor == $new_color) {
3037
            return;
3038
        }
3039
3040
        if (isset($new_color[3])) {
3041
            $this->currentStrokeColor = $new_color;
3042
            $this->addContent(vsprintf("\n%.3F %.3F %.3F %.3F K", $this->currentStrokeColor));
3043
        } else {
3044
            if (isset($new_color[2])) {
3045
                $this->currentStrokeColor = $new_color;
3046
                $this->addContent(vsprintf("\n%.3F %.3F %.3F RG", $this->currentStrokeColor));
3047
            }
3048
        }
3049
    }
3050
3051
    /**
3052
     * Set the graphics state for compositions