1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<?php
class Color {
protected $_r;
protected $_g;
protected $_b;
public function __construct () {
//...
}
public function changeColor ($value) {
if (is_scalar($value) {
// ...
}
elseif (is_array($value) {
// ...
}
elseif (is_object($value) && is_a($value, __CLASS__)) {
// ...
}
else {
throw new InvalidParameterException("Wrong parameter: string, hex, interger, array or Color expected, ".gettype($value)." given");
}
}
public function hex () {
// TODO
}
public function rgb () {
return array($this->_r, $this->_g, $this->_b);
}
} |