1 | <?php |
||
5 | abstract class Avatar { |
||
6 | |||
7 | public static $WHITE = ['r' => 255, 'g' => 255, 'b' => 255]; |
||
8 | public static $GREY = ['r' => 100, 'g' => 100, 'b' => 100]; |
||
9 | |||
10 | /** |
||
11 | * @param int $size |
||
12 | */ |
||
13 | public function setSize($size) |
||
17 | |||
18 | /** |
||
19 | * @return int |
||
20 | */ |
||
21 | public function getSize() |
||
25 | |||
26 | /** |
||
27 | * @return string |
||
28 | */ |
||
29 | public function render() |
||
33 | |||
34 | private function getPicture() |
||
42 | |||
43 | /** |
||
44 | * @param string $directory |
||
45 | * @param mixed $filename |
||
46 | * @return \SplFileObject |
||
47 | */ |
||
48 | public function save($directory, $filename = null) |
||
56 | |||
57 | private function createFileName($filename) |
||
67 | |||
68 | /** |
||
69 | * @param resource $canvas |
||
70 | * @param array $mixColor |
||
71 | * @return int |
||
72 | */ |
||
73 | protected function randomizeColor($canvas, $mixColor) |
||
88 | |||
89 | /** |
||
90 | * @return Avatar |
||
91 | */ |
||
92 | abstract public function getAvatar(); |
||
93 | |||
94 | /** |
||
95 | * @return string |
||
96 | */ |
||
97 | abstract protected function draw(); |
||
98 | |||
99 | } |
||
100 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: