|
Revision 27, 1.8 kB
(checked in by mikey, 2 years ago)
|
converted Example1
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
class Complex |
|---|
| 15 |
{ |
|---|
| 16 |
|
|---|
| 17 |
* data string |
|---|
| 18 |
* |
|---|
| 19 |
* @var string |
|---|
| 20 |
*/ |
|---|
| 21 |
private $data = null; |
|---|
| 22 |
|
|---|
| 23 |
* color data |
|---|
| 24 |
* |
|---|
| 25 |
* @var Color |
|---|
| 26 |
*/ |
|---|
| 27 |
private $color = null; |
|---|
| 28 |
|
|---|
| 29 |
* color string |
|---|
| 30 |
* |
|---|
| 31 |
* @var string |
|---|
| 32 |
*/ |
|---|
| 33 |
private $colorString = null; |
|---|
| 34 |
|
|---|
| 35 |
* an integer example |
|---|
| 36 |
* |
|---|
| 37 |
* @var int |
|---|
| 38 |
*/ |
|---|
| 39 |
private $size = 1; |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
* constructor |
|---|
| 43 |
* |
|---|
| 44 |
* @param string $data |
|---|
| 45 |
*/ |
|---|
| 46 |
public function __construct($data) |
|---|
| 47 |
{ |
|---|
| 48 |
$this->data = $data; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
* set the color string |
|---|
| 53 |
* |
|---|
| 54 |
* @param string $colorString |
|---|
| 55 |
*/ |
|---|
| 56 |
public function setColorString($colorString) |
|---|
| 57 |
{ |
|---|
| 58 |
$this->colorString = $colorString; |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
* set the color |
|---|
| 63 |
* |
|---|
| 64 |
* @param Color $color |
|---|
| 65 |
*/ |
|---|
| 66 |
public function setColor(Color $color) |
|---|
| 67 |
{ |
|---|
| 68 |
$this->color = $color; |
|---|
| 69 |
} |
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 |
* set the size |
|---|
| 73 |
* |
|---|
| 74 |
* @param int $size |
|---|
| 75 |
*/ |
|---|
| 76 |
public function setSize($size) |
|---|
| 77 |
{ |
|---|
| 78 |
$this->size = $size; |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 |
* render all known data |
|---|
| 83 |
* |
|---|
| 84 |
* @return string |
|---|
| 85 |
*/ |
|---|
| 86 |
public function render() |
|---|
| 87 |
{ |
|---|
| 88 |
if (null == $this->color) { |
|---|
| 89 |
return '<font color="' . $this->colorString . '" size="' . $this->size . '">' . $this->data . '</font>'; |
|---|
| 90 |
} else { |
|---|
| 91 |
return '<font title="This text is written in ' . $this->color->getName() . ' (' . $this->color->getColorTitle() . ')" color="' . $this->color->getRGB() . '" size="' . $this->size . '">' . $this->data . '</font>'; |
|---|
| 92 |
} |
|---|
| 93 |
} |
|---|
| 94 |
} |
|---|
| 95 |
?> |
|---|