55/**
66 * Class to retrieve the size and mimetype of images using curl.
77 */
8- class Curl implements ImageInfoInterface
8+ class Curl implements ImageInfoInterface, ImagesInfoInterface
99{
10- use UtilsTrait;
11-
1210 protected static $ mimetypes = [
1311 'image/jpeg ' ,
1412 'image/png ' ,
@@ -39,7 +37,7 @@ class Curl implements ImageInfoInterface
3937 /**
4038 * {@inheritdoc}
4139 */
42- public static function getImagesInfo (array $ urls , array $ config = null , array & $ connections = [] )
40+ public static function getImagesInfo (array $ urls , array $ config = null )
4341 {
4442 if (empty ($ urls )) {
4543 return [];
@@ -48,13 +46,11 @@ public static function getImagesInfo(array $urls, array $config = null, array &$
4846 $ finfo = finfo_open (FILEINFO_MIME_TYPE );
4947 $ curl = curl_multi_init ();
5048 $ result = [];
49+ $ connections = [];
5150
5251 foreach ($ urls as $ k => $ url ) {
5352 if (strpos ($ url ['value ' ], 'data: ' ) === 0 ) {
54- if ($ info = static ::getEmbeddedImageInfo ($ url ['value ' ])) {
55- $ result [$ k ] = array_merge ($ url , $ info );
56- }
57-
53+ $ result [$ k ] = new EmbeddedImage ($ url ['value ' ]);
5854 continue ;
5955 }
6056
@@ -80,18 +76,13 @@ public static function getImagesInfo(array $urls, array $config = null, array &$
8076
8177 foreach ($ connections as $ k => $ connection ) {
8278 curl_multi_remove_handle ($ curl , $ connection ->getConnection ());
83-
84- if (($ info = $ connection ->getInfo ())) {
85- $ result [$ k ] = array_merge ($ urls [$ k ], $ info );
86- }
79+ $ result [$ k ] = $ connection ;
8780 }
8881 }
8982
9083 finfo_close ($ finfo );
9184 curl_multi_close ($ curl );
9285
93- ksort ($ result , SORT_NUMERIC );
94-
9586 return $ result ;
9687 }
9788
@@ -132,13 +123,11 @@ public function getConnection()
132123 }
133124
134125 /**
135- * Get the image info with the format [$width, $height, $mimetype].
136- *
137- * @return null|array
126+ * {@inheritdoc}
138127 */
139128 public function getInfo ()
140129 {
141- return $ this ->info ;
130+ return $ this ->info ?: false ;
142131 }
143132
144133 /**
@@ -158,10 +147,10 @@ public function getUrl()
158147 }
159148
160149 /**
161- * Callback used to save the headers
150+ * Callback used to save the headers.
162151 *
163152 * @param resource $connection
164- * @param string $string
153+ * @param string $string
165154 *
166155 * @return int
167156 */
0 commit comments