Completed
Push — master ( 141360...6dcb9d )
by Adam
03:25
created

Hex::toRbg()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 11
nc 2
nop 0
1
<?php namespace BestServedCold\PhalueObjects\Colour;
2
3
use BestServedCold\PhalueObjects\ValueObject;
4
5
class Hex extends ValueObject
6
{
7
    public function toRbg()
8
    {
9
        $hex = str_replace("#", "", $this->value);
10
11
        if(strlen($hex) == 3) {
12
            $r = hexdec($hex[0].$hex[0]);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $r. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
13
            $g = hexdec($hex[1].$hex[1]);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $g. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
14
            $b = hexdec($hex[2].$hex[2]);
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $b. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
15
        } else {
16
            $r = hexdec($hex[0].$hex[1]);
17
            $g = hexdec($hex[2].$hex[3]);
18
            $b = hexdec($hex[4].$hex[5]);
19
        }
20
21
        return new Rgb(array($r, $g, $b));
22
    }
23
}
24