ColorUtils::colorIdentifier()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 3
dl 0
loc 7
rs 10
1
<?php
2
3
namespace Jackal\ImageMerge\Utils;
4
5
use Jackal\ImageMerge\Model\Color;
6
7
/**
8
 * Class ColorUtils
9
 * @package Jackal\ImageMerge\Utils
10
 */
11
class ColorUtils
12
{
13
    /**
14
     * @param $resource
15
     * @param Color $color
16
     * @param bool $alpha
17
     * @return int
18
     */
19
    public static function colorIdentifier($resource, Color $color, $alpha = false)
20
    {
21
        if (!$alpha) {
22
            return imagecolorallocate($resource, $color->red(), $color->green(), $color->blue());
0 ignored issues
show
Bug introduced by
$color->blue() of type string is incompatible with the type integer expected by parameter $blue of imagecolorallocate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            return imagecolorallocate($resource, $color->red(), $color->green(), /** @scrutinizer ignore-type */ $color->blue());
Loading history...
Bug introduced by
$color->red() of type string is incompatible with the type integer expected by parameter $red of imagecolorallocate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            return imagecolorallocate($resource, /** @scrutinizer ignore-type */ $color->red(), $color->green(), $color->blue());
Loading history...
Bug introduced by
$color->green() of type string is incompatible with the type integer expected by parameter $green of imagecolorallocate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            return imagecolorallocate($resource, $color->red(), /** @scrutinizer ignore-type */ $color->green(), $color->blue());
Loading history...
23
        }
24
25
            return imagecolorallocatealpha($resource, $color->red(), $color->green(), $color->blue(), 127);
0 ignored issues
show
Bug introduced by
$color->red() of type string is incompatible with the type integer expected by parameter $red of imagecolorallocatealpha(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
            return imagecolorallocatealpha($resource, /** @scrutinizer ignore-type */ $color->red(), $color->green(), $color->blue(), 127);
Loading history...
Bug introduced by
$color->green() of type string is incompatible with the type integer expected by parameter $green of imagecolorallocatealpha(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
            return imagecolorallocatealpha($resource, $color->red(), /** @scrutinizer ignore-type */ $color->green(), $color->blue(), 127);
Loading history...
Bug introduced by
$color->blue() of type string is incompatible with the type integer expected by parameter $blue of imagecolorallocatealpha(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

25
            return imagecolorallocatealpha($resource, $color->red(), $color->green(), /** @scrutinizer ignore-type */ $color->blue(), 127);
Loading history...
26
27
    }
28
}
29