Code Duplication    Length = 37-38 lines in 2 locations

lib/Cpdf.php 2 locations

@@ 3080-3117 (lines=38) @@
3077
     * @param string $mode    the blend mode to use
3078
     * @param float  $opacity 0.0 fully transparent, 1.0 fully opaque
3079
     */
3080
    function setLineTransparency($mode, $opacity)
3081
    {
3082
        static $blend_modes = array(
3083
            "Normal",
3084
            "Multiply",
3085
            "Screen",
3086
            "Overlay",
3087
            "Darken",
3088
            "Lighten",
3089
            "ColorDogde",
3090
            "ColorBurn",
3091
            "HardLight",
3092
            "SoftLight",
3093
            "Difference",
3094
            "Exclusion"
3095
        );
3096
3097
        if (!in_array($mode, $blend_modes)) {
3098
            $mode = "Normal";
3099
        }
3100
3101
        // Only create a new graphics state if required
3102
        if ($mode === $this->currentLineTransparency["mode"] &&
3103
            $opacity == $this->currentLineTransparency["opacity"]
3104
        ) {
3105
            return;
3106
        }
3107
3108
        $this->currentLineTransparency["mode"] = $mode;
3109
        $this->currentLineTransparency["opacity"] = $opacity;
3110
3111
        $options = array(
3112
            "BM" => "/$mode",
3113
            "CA" => (float)$opacity
3114
        );
3115
3116
        $this->setGraphicsState($options);
3117
    }
3118
3119
    /**
3120
     * Set current blend mode & opacity for filled objects.
@@ 3131-3167 (lines=37) @@
3128
     * @param string $mode    the blend mode to use
3129
     * @param float  $opacity 0.0 fully transparent, 1.0 fully opaque
3130
     */
3131
    function setFillTransparency($mode, $opacity)
3132
    {
3133
        static $blend_modes = array(
3134
            "Normal",
3135
            "Multiply",
3136
            "Screen",
3137
            "Overlay",
3138
            "Darken",
3139
            "Lighten",
3140
            "ColorDogde",
3141
            "ColorBurn",
3142
            "HardLight",
3143
            "SoftLight",
3144
            "Difference",
3145
            "Exclusion"
3146
        );
3147
3148
        if (!in_array($mode, $blend_modes)) {
3149
            $mode = "Normal";
3150
        }
3151
3152
        if ($mode === $this->currentFillTransparency["mode"] &&
3153
            $opacity == $this->currentFillTransparency["opacity"]
3154
        ) {
3155
            return;
3156
        }
3157
3158
        $this->currentFillTransparency["mode"] = $mode;
3159
        $this->currentFillTransparency["opacity"] = $opacity;
3160
3161
        $options = array(
3162
            "BM" => "/$mode",
3163
            "ca" => (float)$opacity,
3164
        );
3165
3166
        $this->setGraphicsState($options);
3167
    }
3168
3169
    /**
3170
     * draw a line from one set of coordinates to another