ColorConverter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 2
cbo 2
dl 0
loc 75
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A hexToHsv() 0 4 1
A fromHexToHsv() 0 6 1
A hsvToHex() 0 4 1
A fromHsvToHex() 0 6 1
1
<?php namespace Arcanedev\Color;
2
3
use Arcanedev\Color\Contracts\ColorConverter as ColorConverterContract;
4
5
/**
6
 * Class     ColorConverter
7
 *
8
 * @package  Arcanedev\Color
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ColorConverter implements ColorConverterContract
12
{
13
    /* -----------------------------------------------------------------
14
     |  Traits
15
     | -----------------------------------------------------------------
16
     */
17
18
    use Converters\HEXTrait,
19
        Converters\HSVTrait;
20
21
    /* -----------------------------------------------------------------
22
     |  Main Methods
23
     | -----------------------------------------------------------------
24
     */
25
26
    /**
27
     * Convert a HEX color to an HSV array (alias).
28
     *
29
     * @see    fromHexToHsv
30
     *
31
     * @param  string  $hex
32
     *
33
     * @return array
34
     */
35 3
    public static function hexToHsv($hex)
36
    {
37 3
        return (new static)->fromHexToHsv($hex);
38
    }
39
40
    /**
41
     * Convert a HEX color to an HSV array.
42
     *
43
     * @param  string  $hex
44
     *
45
     * @return array
46
     */
47 3
    public function fromHexToHsv($hex)
48
    {
49 3
        list($red, $green, $blue) = $this->fromHexToRgb($hex);
50
51 3
        return $this->fromRgbToHsv($red, $green, $blue);
52
    }
53
54
    /**
55
     * Convert an HSV to HEX color (alias).
56
     *
57
     * @see    fromHsvToHex
58
     *
59
     * @param  float|int  $hue
60
     * @param  float|int  $saturation
61
     * @param  float|int  $value
62
     *
63
     * @return string
64
     */
65 3
    public static function hsvToHex($hue, $saturation, $value)
66
    {
67 3
        return (new static)->fromHsvToHex($hue, $saturation, $value);
68
    }
69
70
    /**
71
     * Convert an HSV to HEX color.
72
     *
73
     * @param  float|int  $hue
74
     * @param  float|int  $saturation
75
     * @param  float|int  $value
76
     *
77
     * @return string
78
     */
79 3
    public function fromHsvToHex($hue, $saturation, $value)
80
    {
81 3
        list($red, $green, $blue) = $this->fromHsvToRgb($hue, $saturation, $value);
82
83 3
        return $this->fromRgbToHex($red, $green, $blue);
84
    }
85
}
86