Skip to content

Commit 0484675

Browse files
committed
Merge pull request #7 from FinesseRus/master
Added PHPDoc
2 parents a6d5cc8 + 76192e2 commit 0484675

File tree

5 files changed

+99
-21
lines changed

5 files changed

+99
-21
lines changed

lib/Primal/Color/CMYKColor.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,39 @@ class CMYKColor extends Color {
99
public $black = 100;
1010
public $alpha = 1;
1111

12-
function __construct($c = 0, $m = 0, $y = 0, $k = 100, $a=1) {
12+
public function __construct($c = 0, $m = 0, $y = 0, $k = 100, $a=1) {
1313
$this->cyan = $c;
1414
$this->magenta = $m;
1515
$this->yellow = $y;
1616
$this->black = $k;
1717
$this->alpha = $a;
1818
}
1919

20-
function toHSV() {
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
public function toHSV() {
2124
return $this->toRGB()->toHSV();
2225
}
2326

24-
function toHSL() {
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
public function toHSL() {
2531
return $this->toRGB()->toHSL();
2632
}
2733

28-
function toCMYK() {
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function toCMYK() {
2938
return clone $this;
3039
}
3140

32-
function toRGB() {
41+
/**
42+
* {@inheritdoc}
43+
*/
44+
public function toRGB() {
3345
$c = ((int)$this->cyan % 100) / 100;
3446
$m = ((int)$this->magenta % 100) / 100;
3547
$y = ((int)$this->yellow % 100) / 100;
@@ -42,7 +54,10 @@ function toRGB() {
4254
return new RGBColor($r * 255, $g * 255, $b * 255, $this->alpha);
4355
}
4456

45-
function toCSS($alpha = null) {
57+
/**
58+
* {@inheritdoc}
59+
*/
60+
public function toCSS($alpha = null) {
4661
return ($alpha === true || $this->alpha < 1) && $alpha !== false
4762
? sprintf('device-cmyk(%d%%, %d%%, %d%%, %d%%, %s)',
4863
$this->cyan, $this->magenta, $this->yellow, $this->black, $this->alpha)

lib/Primal/Color/Color.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,29 @@
44

55
abstract class Color {
66

7+
/**
8+
* @return HSVColor
9+
*/
710
abstract function toHSV();
811

12+
/**
13+
* @return HSLColor
14+
*/
915
abstract function toHSL();
1016

17+
/**
18+
* @return RGBColor
19+
*/
1120
abstract function toRGB();
1221

22+
/**
23+
* @return CMYKColor
24+
*/
1325
abstract function toCMYK();
1426

27+
/**
28+
* @return string
29+
*/
1530
abstract function toCSS();
1631
}
1732

lib/Primal/Color/HSLColor.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,37 @@ class HSLColor extends Color {
88
public $luminance = 0;
99
public $alpha = 1;
1010

11-
function __construct($h = 0, $s = 0, $l = 0, $a=1) {
11+
public function __construct($h = 0, $s = 0, $l = 0, $a=1) {
1212
$this->hue = $h;
1313
$this->saturation = $s;
1414
$this->luminance = $l;
1515
$this->alpha = $a;
1616
}
1717

18+
/**
19+
* {@inheritdoc}
20+
*/
1821
public function toHSV() {
1922
return $this->toRGB()->toHSV();
2023
}
2124

25+
/**
26+
* {@inheritdoc}
27+
*/
2228
public function toHSL() {
2329
return clone $this;
2430
}
2531

26-
function toCMYK() {
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function toCMYK() {
2736
return $this->toRGB()->toCMYK();
2837
}
2938

39+
/**
40+
* {@inheritdoc}
41+
*/
3042
public function toRGB() {
3143
$h = ($this->hue % 360) / 360;
3244
$s = ($this->saturation % 101) / 100;
@@ -55,6 +67,9 @@ protected static function HueToFactor($p, $q, $t) {
5567
return $p;
5668
}
5769

70+
/**
71+
* {@inheritdoc}
72+
*/
5873
public function toCSS($alpha = null) {
5974
return ($alpha === true || $this->alpha < 1) && $alpha !== false
6075
? sprintf('hsla(%d, %d, %d, %s)', $this->hue, $this->saturation, $this->luminance, $this->alpha)

lib/Primal/Color/HSVColor.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,38 @@ class HSVColor extends Color {
88
public $value = 0;
99
public $alpha = 1;
1010

11-
function __construct($h = 0, $s = 0, $v = 0, $a=1) {
11+
public function __construct($h = 0, $s = 0, $v = 0, $a=1) {
1212
$this->hue = $h;
1313
$this->saturation = $s;
1414
$this->value = $v;
1515
$this->alpha = $a;
1616
}
1717

18-
function toHSV() {
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function toHSV() {
1922
return clone $this;
2023
}
2124

22-
function toHSL() {
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function toHSL() {
2329
return $this->toRGB()->toHSL();
2430
}
2531

26-
function toCMYK() {
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function toCMYK() {
2736
return $this->toRGB()->toCMYK();
2837
}
2938

30-
function toRGB() {
39+
/**
40+
* {@inheritdoc}
41+
*/
42+
public function toRGB() {
3143
$h = ($this->hue % 360) / 360;
3244
$s = ($this->saturation % 101) / 100;
3345
$v = ($this->value % 101) / 100;
@@ -73,7 +85,10 @@ function toRGB() {
7385
return new RGBColor($r * 255, $g * 255, $b * 255, $a);
7486
}
7587

76-
function toCSS($alpha = null) {
88+
/**
89+
* {@inheritdoc}
90+
*/
91+
public function toCSS($alpha = null) {
7792
return $this->toRGB()->toCSS($alpha);
7893
}
7994

lib/Primal/Color/RGBColor.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@ class RGBColor extends Color {
88
public $blue = 0;
99
public $alpha = 1;
1010

11-
function __construct($r = 0, $g = 0, $b = 0, $a=1) {
11+
public function __construct($r = 0, $g = 0, $b = 0, $a=1) {
1212
$this->red = $r;
1313
$this->green = $g;
1414
$this->blue = $b;
1515
$this->alpha = $a;
1616
}
1717

18-
function toHSV() {
18+
/**
19+
* {@inheritdoc}
20+
*/
21+
public function toHSV() {
1922
$r = ((int)$this->red % 256) / 255;
2023
$g = ((int)$this->green % 256) / 255;
2124
$b = ((int)$this->blue % 256) / 255;
@@ -46,7 +49,10 @@ function toHSV() {
4649
return new HSVColor($h*360, $s*100, $v*100, $a);
4750
}
4851

49-
function toHSL() {
52+
/**
53+
* {@inheritdoc}
54+
*/
55+
public function toHSL() {
5056
$r = ((int)$this->red % 256) / 255;
5157
$g = ((int)$this->green % 256) / 255;
5258
$b = ((int)$this->blue % 256) / 255;
@@ -77,7 +83,10 @@ function toHSL() {
7783
return new HSLColor($h*360, $s*100, $l*100, $a);
7884
}
7985

80-
function toCMYK() {
86+
/**
87+
* {@inheritdoc}
88+
*/
89+
public function toCMYK() {
8190
$r = ((int)$this->red % 256) / 255;
8291
$g = ((int)$this->green % 256) / 255;
8392
$b = ((int)$this->blue % 256) / 255;
@@ -95,17 +104,26 @@ function toCMYK() {
95104
return new CMYKColor($c*100, $m*100, $y*100, $k*100, $a);
96105
}
97106

98-
function toRGB() {
107+
/**
108+
* {@inheritdoc}
109+
*/
110+
public function toRGB() {
99111
return clone $this;
100112
}
101113

102-
function toCSS($alpha = null) {
114+
/**
115+
* {@inheritdoc}
116+
*/
117+
public function toCSS($alpha = null) {
103118
return ($alpha === true || $this->alpha < 1) && $alpha !== false
104119
? sprintf('rgba(%d, %d, %d, %s)', $this->red, $this->green, $this->blue, $this->alpha)
105120
: sprintf('rgb(%d, %d, %d)', $this->red, $this->green, $this->blue);
106121
}
107122

108-
function toHex() {
123+
/**
124+
* {@inheritdoc}
125+
*/
126+
public function toHex() {
109127
$stack = array('#');
110128
$stack[] = str_pad(dechex(min(255, round($this->red ))), 2, '0', STR_PAD_LEFT);
111129
$stack[] = str_pad(dechex(min(255, round($this->green))), 2, '0', STR_PAD_LEFT);

0 commit comments

Comments
 (0)