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

Hex   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 19
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A toRbg() 0 16 2
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