1 | <?php |
||
12 | class Thumb { |
||
13 | |||
14 | private $url; |
||
15 | private $cache = null; |
||
16 | private $default = null; |
||
17 | private $opacity = 100; |
||
18 | |||
19 | /** @var AdapterInterface Biblioteca responsável pela thumb */ |
||
20 | public $adapter; |
||
21 | |||
22 | /** @var GD */ |
||
23 | private $image; |
||
24 | private $imageUrl; |
||
25 | private $width; |
||
26 | private $height; |
||
27 | private $padding; |
||
28 | private $quality; |
||
29 | private $mode; |
||
30 | static private $modes = ['normal', 'center', 'padding']; |
||
31 | |||
32 | /** |
||
33 | * Construtor |
||
34 | */ |
||
35 | public function __construct() { |
||
41 | |||
42 | public function setCache($cache) { |
||
45 | |||
46 | /** |
||
47 | * Define a imagem padrão caso não encontre a imagem |
||
48 | * @param string $default |
||
49 | * @param int $opacity |
||
50 | */ |
||
51 | public function setDefault($default, $opacity) { |
||
55 | |||
56 | /** |
||
57 | * Inicia configurações com base na url |
||
58 | * @param string $url |
||
59 | */ |
||
60 | public function config($url) { |
||
70 | |||
71 | /** |
||
72 | * Define o nome da imagem |
||
73 | * é possivel utililizar dois modos de apelido para a imagem |
||
74 | * diretorio/real/[APELIDO]_nome-imagem.jpg |
||
75 | * diretorio/real/nome-imagem/[APELIDO].jpg |
||
76 | */ |
||
77 | private function setImageUrl($config) { |
||
86 | |||
87 | /** @param string $mode */ |
||
88 | private function setMode($mode) { |
||
93 | |||
94 | /** |
||
95 | * Define as dimensões |
||
96 | * @param mixed[] $config |
||
97 | */ |
||
98 | private function setSize(&$config) { |
||
113 | |||
114 | /** Exibe a thumb final */ |
||
115 | public function show() { |
||
126 | |||
127 | /** @return boolean */ |
||
128 | private function validate() { |
||
134 | |||
135 | /** |
||
136 | * Salva a imagem no diretorio de cache se necessário |
||
137 | * @param GD $thumb |
||
138 | */ |
||
139 | private function saveCache($thumb) { |
||
149 | |||
150 | /** Exibe a imagem default */ |
||
151 | private function showDefault() { |
||
158 | |||
159 | /** |
||
160 | * Aplica opacidade na imagem |
||
161 | * @param GD $thumb |
||
162 | */ |
||
163 | private function applyOpacity($thumb) { |
||
168 | |||
169 | /* Modos */ |
||
170 | |||
171 | /** @return GD */ |
||
172 | protected function normal() { |
||
175 | |||
176 | /** @return GD */ |
||
177 | protected function center() { |
||
180 | |||
181 | /** @return GD */ |
||
182 | protected function padding() { |
||
185 | |||
186 | } |
||
187 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: