root/tags/RELEASE_0_2_0/examples/Complex2.php

Revision 54, 1.7 kB (checked in by schst, 2 years ago)

Removed trailing spaces, converted tabs to spaces

Line 
1 <?php
2 /**
3  * example complex class
4  *
5  * @author  Stephan Schmidt <stephan.schmidt@schlund.de>
6  * @author  Frank Kleine <frank.kleine@schlund.de>
7  */
8 /**
9  * example complex class
10  *
11  * @package     XJConf
12  * @subpackage  examples
13  */
14 class Complex2
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 = null)
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 ?>
Note: See TracBrowser for help on using the browser.