1 | <?php |
||
16 | abstract class Basic |
||
17 | { |
||
18 | /** |
||
19 | * Image GD |
||
20 | * @var resource |
||
21 | */ |
||
22 | protected $img; |
||
23 | /** |
||
24 | * Image Height |
||
25 | * @var int |
||
26 | */ |
||
27 | protected $imgHeight = 0; |
||
28 | /** |
||
29 | * Image Width |
||
30 | * @var int |
||
31 | */ |
||
32 | protected $imgWidth = 0; |
||
33 | |||
34 | /** |
||
35 | * @return int height of the image in pixels |
||
36 | */ |
||
37 | 1 | public function getHeight() |
|
41 | |||
42 | /** |
||
43 | * @return int Number of bytes to represent a row of this image |
||
44 | */ |
||
45 | public function getHeightBytes() |
||
46 | { |
||
47 | return (int)(($this->imgHeight + 7) / 8); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return int Width of the image |
||
52 | */ |
||
53 | 1 | public function getWidth() |
|
57 | |||
58 | /** |
||
59 | * @return int Number of bytes to represent a row of this image |
||
60 | */ |
||
61 | 1 | public function getWidthBytes() |
|
65 | |||
66 | /** |
||
67 | * zGetDimImage |
||
68 | * Get width and height of resource image |
||
69 | * and save in properties |
||
70 | * @return array with dimentions of image |
||
71 | */ |
||
72 | 7 | protected function getDimImage() |
|
81 | |||
82 | /** |
||
83 | * @return boolean True if GD is supported, false otherwise (a wrapper for the version, for mocking in tests) |
||
84 | */ |
||
85 | 10 | protected function isGdSupported() |
|
89 | |||
90 | /** |
||
91 | * @return boolean True if GD is loaded, false otherwise |
||
92 | */ |
||
93 | 10 | protected function isGdLoaded() |
|
98 | |||
99 | /** |
||
100 | * identifyImg |
||
101 | * Identifies image file type |
||
102 | * @param string $filename |
||
103 | * @return string |
||
104 | */ |
||
105 | 7 | protected function identifyImg($filename) |
|
129 | } |
||
130 |
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: