@@ -27,7 +27,7 @@ protected static function identifier() {
2727 parent ::identifier () . ' fopen ' ;
2828 }
2929
30- protected function __construct ($ api_key , $ after_compress_callback ) {
30+ protected function __construct ( $ api_key , $ after_compress_callback ) {
3131 parent ::__construct ( $ after_compress_callback );
3232
3333 $ this ->api_key = $ api_key ;
@@ -46,14 +46,14 @@ public function get_key() {
4646 }
4747
4848 public function limit_reached () {
49- return $ this ->last_error_code == 429 ;
49+ return 429 == $ this ->last_error_code ;
5050 }
5151
5252 protected function validate () {
5353 $ params = $ this ->request_options ( 'POST ' );
5454 list ($ details , $ headers , $ status_code ) = $ this ->request ( $ params );
5555
56- if ( $ status_code == 429 || $ status_code == 400 ) {
56+ if ( 429 == $ status_code || 400 == $ status_code ) {
5757 return true ;
5858 } else if ( is_array ( $ details ) && isset ( $ details ['error ' ] ) ) {
5959 throw new Tiny_Exception (
@@ -70,7 +70,7 @@ protected function validate() {
7070 }
7171 }
7272
73- protected function compress ($ input , $ resize_opts , $ preserve_opts ) {
73+ protected function compress ( $ input , $ resize_opts , $ preserve_opts ) {
7474 $ params = $ this ->request_options ( 'POST ' , $ input );
7575 list ($ details , $ headers , $ status_code ) = $ this ->request ( $ params );
7676
@@ -87,7 +87,7 @@ protected function compress($input, $resize_opts, $preserve_opts) {
8787 'Tinify\Exception ' ,
8888 $ status_code
8989 );
90- } else if ( $ output_url === null ) {
90+ } else if ( null === $ output_url ) {
9191 throw new Tiny_Exception (
9292 'Could not find output location ' ,
9393 'Tinify\Exception '
@@ -129,13 +129,13 @@ protected function compress($input, $resize_opts, $preserve_opts) {
129129 'width ' => intval ( $ headers ['image-width ' ] ),
130130 'height ' => intval ( $ headers ['image-height ' ] ),
131131 'ratio ' => round ( strlen ( $ output ) / strlen ( $ input ), 4 ),
132- )
132+ ),
133133 );
134134
135135 return array ( $ output , $ meta );
136136 }
137137
138- private function request ($ params , $ url = Tiny_Config::URL ) {
138+ private function request ( $ params , $ url = Tiny_Config::URL ) {
139139 $ context = stream_context_create ( $ params );
140140 $ request = fopen ( $ url , 'rb ' , false , $ context );
141141
@@ -172,7 +172,7 @@ private function request($params, $url = Tiny_Config::URL) {
172172 return array ( $ response , $ headers , $ status_code );
173173 }
174174
175- private function parse_status_code ($ headers ) {
175+ private function parse_status_code ( $ headers ) {
176176 if ( $ headers && count ( $ headers ) > 0 ) {
177177 $ http_code_values = explode ( ' ' , $ headers [0 ] );
178178 if ( count ( $ http_code_values ) > 1 ) {
@@ -182,7 +182,7 @@ private function parse_status_code($headers) {
182182 return null ;
183183 }
184184
185- private function parse_headers ($ headers ) {
185+ private function parse_headers ( $ headers ) {
186186 $ res = array ();
187187 foreach ( $ headers as $ header ) {
188188 $ split = explode ( ': ' , $ header , 2 );
@@ -193,7 +193,7 @@ private function parse_headers($headers) {
193193 return $ res ;
194194 }
195195
196- private function request_options ($ method , $ body = null ) {
196+ private function request_options ( $ method , $ body = null ) {
197197 return array (
198198 'http ' => array (
199199 'method ' => $ method ,
@@ -210,11 +210,11 @@ private function request_options($method, $body = null) {
210210 'ssl ' => array (
211211 'cafile ' => $ this ->get_ca_file (),
212212 'verify_peer ' => true ,
213- )
213+ ),
214214 );
215215 }
216216
217- private function output_request_options ($ resize_opts , $ preserve_opts ) {
217+ private function output_request_options ( $ resize_opts , $ preserve_opts ) {
218218 $ body = array ();
219219
220220 if ( $ preserve_opts ) {
@@ -237,9 +237,9 @@ private static function get_ca_file() {
237237 return dirname ( __FILE__ ) . '/data/cacert.pem ' ;
238238 }
239239
240- private static function decode ($ text ) {
240+ private static function decode ( $ text ) {
241241 $ result = json_decode ( $ text , true );
242- if ( $ result === null ) {
242+ if ( null === $ result ) {
243243 $ message = sprintf (
244244 'JSON: %s [%d] ' ,
245245 (PHP_VERSION_ID >= 50500 ? json_last_error_msg () : 'Unknown error ' ),
0 commit comments