1 | <?php |
||
9 | class RandImgProvider extends Base |
||
10 | { |
||
11 | /** |
||
12 | * @var string |
||
13 | */ |
||
14 | private $baseUrl = 'http://www.rand-img.com'; |
||
15 | |||
16 | /** |
||
17 | * Utility method for provide random numbers for the urls. |
||
18 | * |
||
19 | * @return integer Random number. |
||
20 | */ |
||
21 | 9 | private function getRandNumber($min = 1, $max = 1000000) |
|
25 | |||
26 | /** |
||
27 | * Downloads a file from the specified url and saves it in the |
||
28 | * full path passed. It uses cURL. |
||
29 | * |
||
30 | * @param string $url The url of the image to download |
||
31 | * @param string $filePath The full path where store the image |
||
32 | * |
||
33 | * @return bool true if success, else remove the image and return false. |
||
34 | */ |
||
35 | 9 | private function getRemoteImage($url, $filePath) |
|
50 | |||
51 | /** |
||
52 | * Obtain the full path for an image file. |
||
53 | * |
||
54 | * @param string $dir The directory where store the image to download |
||
55 | * @param string $type The image format |
||
56 | * @throws InvalidArgumentException if $dir is not a directory or is not writeable |
||
57 | * |
||
58 | * @return string full path. |
||
59 | */ |
||
60 | 15 | private function getFullPath($dir = null, $type = 'jpg') |
|
70 | |||
71 | /** |
||
72 | * Generate a random image url. |
||
73 | * |
||
74 | * @param integer $width |
||
75 | * @param integer $height |
||
76 | * @param string $category The image topic. Defaults to empty (no category). |
||
77 | * @param array $params Optional associative array with the list of parameters for the image. |
||
78 | * You can see a list of parameters and its possible values in |
||
79 | * https://github.com/SiroDiaz/RandImgProvider/blob/master/README.md |
||
80 | * |
||
81 | * @return string Returns the phrase passed in |
||
82 | */ |
||
83 | 30 | public function imageUrl($width = 720, $height = 480, $category = '', array $params = []) |
|
100 | |||
101 | /** |
||
102 | * Helper method that generate a squared image url. |
||
103 | * |
||
104 | * @param int $width The image width. Default to 720px. |
||
105 | * @param array $params Optional associative array with the list of parameters for the image. |
||
106 | */ |
||
107 | 9 | public function squaredImageUrl($width = 720, $category = '', array $params = []) |
|
111 | |||
112 | /** |
||
113 | * Generate a random gif url. It can attach |
||
114 | * a random number to avoid that multiple gifs loaded |
||
115 | * in the page will be all the same gif. |
||
116 | * |
||
117 | * @param bool $rand Defaults to false |
||
118 | */ |
||
119 | 9 | public function gifUrl($rand = false) |
|
125 | |||
126 | /** |
||
127 | * Downloads an image to the specified directory. |
||
128 | * |
||
129 | * @param mixed $dir string or null. If null PHP will use the default temporary directory. |
||
130 | * @param integer $width |
||
131 | * @param integer $height |
||
132 | * @param string $category |
||
133 | * @param array $params |
||
134 | * @throws InvalidArgumentException If not a directory or writeable |
||
135 | * |
||
136 | * @return string Filename with the path |
||
137 | */ |
||
138 | 9 | public function image($dir = null, $width = 720, $height = 480, $category = '', array $params = []) |
|
148 | |||
149 | /** |
||
150 | * Downloads a gif to the specified directory. |
||
151 | * |
||
152 | * @param mixed $dir string or null. If null PHP will use the default temporary directory. |
||
153 | * @throws InvalidArgumentException If not a directory or writeable. |
||
154 | * |
||
155 | * @return string Filename with the path |
||
156 | */ |
||
157 | 6 | public function gif($dir = null) |
|
167 | } |
||
168 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.