@@ -28,19 +28,19 @@ public function getPlaceholder(Request $request, string $dimensions, string $for
2828 [$ width , $ height ] = self ::parseDimensions ($ dimensions );
2929
3030 $ bgColor = $ request ->query ->get ('bgColor ' , '#2b2d42 ' );
31- $ bgColor = $ bgColor === ' random ' ? null : $ bgColor ;
31+ $ bgColor = ' random ' === $ bgColor ? null : $ bgColor ;
3232
3333 $ textColor = $ request ->query ->get ('textColor ' , '#edf2f4 ' );
34- $ textColor = $ textColor === ' random ' ? null : $ textColor ;
34+ $ textColor = ' random ' === $ textColor ? null : $ textColor ;
3535
3636 $ projectRoot = $ this ->getParameter ('kernel.project_dir ' );
3737
3838 ob_start ();
3939 (new ImageGenerator (
40- $ width . 'x ' . $ height ,
40+ $ width. 'x ' . $ height ,
4141 $ textColor ,
4242 $ bgColor ,
43- $ projectRoot . '/var/fonts/Noto.ttf ' ,
43+ $ projectRoot. '/var/fonts/Noto.ttf ' ,
4444 min ($ width , $ height ) * 0.125 ,
4545 2
4646 ))
@@ -62,7 +62,7 @@ public function getPlaceholder(Request $request, string $dimensions, string $for
6262 public function getSpace (Request $ request , string $ dimensions , string $ category = 'random ' , string $ format = 'png ' ): Response
6363 {
6464 [$ width , $ height ] = self ::parseDimensions ($ dimensions );
65- $ url = sprintf ('https://api.lorem.space/image%s?w=%s&h=%s ' , $ category && $ category !== ' random ' ? '/ ' .$ category : '' , $ width ? $ width : '' , $ height ? $ height : '' );
65+ $ url = sprintf ('https://api.lorem.space/image%s?w=%s&h=%s ' , $ category && ' random ' !== $ category ? '/ ' .$ category : '' , $ width ? $ width : '' , $ height ? $ height : '' );
6666 $ client = HttpClient::create ();
6767 $ response = $ client ->request ('GET ' , $ url );
6868
@@ -161,7 +161,7 @@ private function renderImage(string $content, string $format = 'png'): Response
161161 $ content = ob_get_clean ();
162162
163163 $ response = new Response ();
164- $ disposition = $ response ->headers ->makeDisposition (ResponseHeaderBag::DISPOSITION_INLINE , uniqid ('' , true ). ". $ {format}" );
164+ $ disposition = $ response ->headers ->makeDisposition (ResponseHeaderBag::DISPOSITION_INLINE , uniqid ('' , true ).". $ {format}" );
165165 $ response ->headers ->set ('Content-Disposition ' , $ disposition );
166166 $ response ->headers ->set ('Content-Type ' , $ mimeType );
167167 $ response ->setContent ($ content );
@@ -172,10 +172,11 @@ private function renderImage(string $content, string $format = 'png'): Response
172172 private static function parseDimensions (string $ dimensions ): array
173173 {
174174 $ dimensions = explode ('x ' , $ dimensions );
175- if (count ( $ dimensions ) === 1 ) {
175+ if (1 === count ( $ dimensions ) ) {
176176 $ dimensions [1 ] = $ dimensions [0 ];
177177 }
178178 $ dimensions = implode ('x ' , $ dimensions );
179+
179180 return explode ('x ' , $ dimensions );
180181 }
181182}
0 commit comments