@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | public function hasError() |
| 39 | 39 | { |
| 40 | - if(count( $this->selectors) == 0) { |
|
| 40 | + if (count($this->selectors) == 0) { |
|
| 41 | 41 | throw new NoSelectorsConfigured("NoSelectorsConfigured", 1); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -45,12 +45,12 @@ discard block |
||
| 45 | 45 | // é página de erro da receita federal |
| 46 | 46 | $node = $this->filter($this->selectors['error']); |
| 47 | 47 | |
| 48 | - if($node->count()){ |
|
| 49 | - throw new ErrorFoundData( $this->clearString($node->text()), 1); |
|
| 48 | + if ($node->count()) { |
|
| 49 | + throw new ErrorFoundData($this->clearString($node->text()), 1); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // CNPJ informado é válido? |
| 53 | - if($this->filter('#imgCaptcha')->count()){ |
|
| 53 | + if ($this->filter('#imgCaptcha')->count()) { |
|
| 54 | 54 | throw new InvalidCaptcha('Captcha inválido', 99); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -67,16 +67,16 @@ discard block |
||
| 67 | 67 | $this->hasError(); |
| 68 | 68 | |
| 69 | 69 | foreach ($this->selectors as $name => $selector) { |
| 70 | - if(is_string($selector)){ |
|
| 70 | + if (is_string($selector)) { |
|
| 71 | 71 | $node = $this->scrap($selector); |
| 72 | 72 | |
| 73 | - if($node->count()){ |
|
| 73 | + if ($node->count()) { |
|
| 74 | 74 | $scrapped[$name] = $this->clearString($node->text()); |
| 75 | 75 | } |
| 76 | - }elseif(is_array($selector)){ |
|
| 76 | + }elseif (is_array($selector)) { |
|
| 77 | 77 | foreach ($selector as $selector => $repeat) { |
| 78 | 78 | $node = $this->scrap($selector); |
| 79 | - if($node->count()){ |
|
| 79 | + if ($node->count()) { |
|
| 80 | 80 | foreach ($node->filter($repeat) as $loop) |
| 81 | 81 | { |
| 82 | 82 | $scrapped[$name][] = $this->clearString($loop->nodeValue); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | private function hasRequested() |
| 90 | 90 | { |
| 91 | - if(!$this->instanceResponse) { |
|
| 91 | + if (!$this->instanceResponse) { |
|
| 92 | 92 | throw new NoServiceCall("No request from this service, please call first method request", 1); |
| 93 | 93 | } |
| 94 | 94 | |
@@ -119,13 +119,13 @@ discard block |
||
| 119 | 119 | CURLOPT_HTTPHEADER => array( |
| 120 | 120 | "Pragma: no-cache", |
| 121 | 121 | "Origin: " . $this->configurations['base'], |
| 122 | - "Host: ". array_get($this->configurations, 'headers.Host'), |
|
| 122 | + "Host: " . array_get($this->configurations, 'headers.Host'), |
|
| 123 | 123 | "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0", |
| 124 | 124 | "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", |
| 125 | 125 | "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3", |
| 126 | 126 | "Accept-Encoding: gzip, deflate", |
| 127 | 127 | "Referer: " . $this->configurations['home'], |
| 128 | - "Cookie: flag=1; ". $this->cookie, |
|
| 128 | + "Cookie: flag=1; " . $this->cookie, |
|
| 129 | 129 | "Connection: keep-alive" |
| 130 | 130 | ), |
| 131 | 131 | CURLOPT_RETURNTRANSFER => true, |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->captcha = $curl->response(); |
| 145 | 145 | |
| 146 | 146 | // é uma imagem o retorno? |
| 147 | - if(@imagecreatefromstring($this->captcha) == false) |
|
| 147 | + if (@imagecreatefromstring($this->captcha) == false) |
|
| 148 | 148 | { |
| 149 | 149 | throw new NoCaptchaResponse('Não foi possível capturar o captcha'); |
| 150 | 150 | } |
@@ -218,13 +218,13 @@ discard block |
||
| 218 | 218 | CURLOPT_HTTPHEADER => array( |
| 219 | 219 | "Pragma: no-cache", |
| 220 | 220 | "Origin: " . $this->configurations['base'], |
| 221 | - "Host: ". array_get($configurations, 'headers.Host'), |
|
| 221 | + "Host: " . array_get($configurations, 'headers.Host'), |
|
| 222 | 222 | "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0", |
| 223 | 223 | "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", |
| 224 | 224 | "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3", |
| 225 | 225 | "Accept-Encoding: gzip, deflate", |
| 226 | - "Referer: " . $this->configurations['home'] .'?cnpj='. $document, |
|
| 227 | - "Cookie: flag=1; ". $cookie, |
|
| 226 | + "Referer: " . $this->configurations['home'] . '?cnpj=' . $document, |
|
| 227 | + "Cookie: flag=1; " . $cookie, |
|
| 228 | 228 | "Connection: keep-alive" |
| 229 | 229 | ), |
| 230 | 230 | CURLOPT_RETURNTRANSFER => 1, |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | // vamos capturar retorno, que deverá ser o HTML para scrapping |
| 244 | 244 | $html = $curl->response(); |
| 245 | 245 | |
| 246 | - if(empty($html)) { |
|
| 246 | + if (empty($html)) { |
|
| 247 | 247 | throw new NoServiceResponse('No response from service', 99); |
| 248 | 248 | } |
| 249 | 249 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | $node = $this->scrap($this->selectors['razao_social']); |
| 40 | 40 | |
| 41 | - if(!$node->count()) |
|
| 41 | + if (!$node->count()) |
|
| 42 | 42 | { |
| 43 | 43 | throw new ErrorFoundData($this->clearString($this->scrap($this->selectors['error'])->text()), 1); |
| 44 | 44 | } |
@@ -56,16 +56,16 @@ discard block |
||
| 56 | 56 | $this->hasError(); |
| 57 | 57 | |
| 58 | 58 | foreach ($this->selectors as $name => $selector) { |
| 59 | - if(is_string($selector)){ |
|
| 59 | + if (is_string($selector)) { |
|
| 60 | 60 | $node = $this->scrap($selector); |
| 61 | 61 | |
| 62 | - if($node->count()){ |
|
| 62 | + if ($node->count()) { |
|
| 63 | 63 | $scrapped[$name] = $this->clearString($node->text()); |
| 64 | 64 | } |
| 65 | - }elseif(is_array($selector)){ |
|
| 65 | + }elseif (is_array($selector)) { |
|
| 66 | 66 | foreach ($selector as $selector => $repeat) { |
| 67 | 67 | $node = $this->scrap($selector); |
| 68 | - if($node->count()){ |
|
| 68 | + if ($node->count()) { |
|
| 69 | 69 | foreach ($node->filter($repeat) as $loop) |
| 70 | 70 | { |
| 71 | 71 | $scrapped[$name][] = $this->clearString($loop->nodeValue); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | private function hasRequested() |
| 88 | 88 | { |
| 89 | - if(!$this->instanceResponse) { |
|
| 89 | + if (!$this->instanceResponse) { |
|
| 90 | 90 | throw new NoServiceCall("No request from this service, please call first method request", 1); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | array_get($this->configurations, 'selectors.image') |
| 106 | 106 | ); |
| 107 | 107 | |
| 108 | - if(!$imageSrc->count()){ |
|
| 108 | + if (!$imageSrc->count()) { |
|
| 109 | 109 | throw new ImageNotFound("Impossible to crawler image from response", 1); |
| 110 | 110 | } |
| 111 | 111 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | array_get($this->configurations, 'selectors.paramBot') |
| 114 | 114 | ); |
| 115 | 115 | |
| 116 | - if(!$paramBot->count()){ |
|
| 116 | + if (!$paramBot->count()) { |
|
| 117 | 117 | throw new ImageNotFound("Impossible to crawler parambot from response", 1); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -135,13 +135,13 @@ discard block |
||
| 135 | 135 | CURLOPT_HTTPHEADER => array( |
| 136 | 136 | "Pragma: no-cache", |
| 137 | 137 | "Origin: " . $this->configurations['base'], |
| 138 | - "Host: ". array_get($this->configurations, 'headers.Host'), |
|
| 138 | + "Host: " . array_get($this->configurations, 'headers.Host'), |
|
| 139 | 139 | "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0", |
| 140 | 140 | "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", |
| 141 | 141 | "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3", |
| 142 | 142 | "Accept-Encoding: gzip, deflate", |
| 143 | 143 | "Referer: " . $this->configurations['captcha'], |
| 144 | - "Cookie: flag=1; ". $this->cookie, |
|
| 144 | + "Cookie: flag=1; " . $this->cookie, |
|
| 145 | 145 | "Connection: keep-alive" |
| 146 | 146 | ), |
| 147 | 147 | CURLOPT_RETURNTRANSFER => true, |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $this->captcha = $curl->response(); |
| 161 | 161 | |
| 162 | 162 | // é uma imagem o retorno? |
| 163 | - if(@imagecreatefromstring($this->captcha) == false) |
|
| 163 | + if (@imagecreatefromstring($this->captcha) == false) |
|
| 164 | 164 | { |
| 165 | 165 | throw new NoCaptchaResponse('Não foi possível capturar o captcha'); |
| 166 | 166 | } |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2", |
| 240 | 240 | "Accept-Encoding: gzip, deflate", |
| 241 | 241 | "Referer: http://pfeserv1.fazenda.sp.gov.br/sintegrapfe/consultaSintegraServlet", |
| 242 | - "Cookie: flag=1; ". $cookie, |
|
| 242 | + "Cookie: flag=1; " . $cookie, |
|
| 243 | 243 | "Connection: keep-alive" |
| 244 | 244 | ), |
| 245 | 245 | CURLOPT_RETURNTRANSFER => 1, |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | // vamos capturar retorno, que deverá ser o HTML para scrapping |
| 259 | 259 | $html = $curl->response(); |
| 260 | 260 | |
| 261 | - if(empty($html)) { |
|
| 261 | + if (empty($html)) { |
|
| 262 | 262 | throw new NoServiceResponse('No response from service', 99); |
| 263 | 263 | } |
| 264 | 264 | |
@@ -28,10 +28,10 @@ |
||
| 28 | 28 | */ |
| 29 | 29 | public function service($service) |
| 30 | 30 | { |
| 31 | - if(array_key_exists($service, $this->services) && class_exists($this->services[$service])){ |
|
| 31 | + if (array_key_exists($service, $this->services) && class_exists($this->services[$service])) { |
|
| 32 | 32 | $service = new $this->services[$service]; |
| 33 | 33 | |
| 34 | - if($service instanceof ServiceInterface){ |
|
| 34 | + if ($service instanceof ServiceInterface) { |
|
| 35 | 35 | return $this->service = $service; |
| 36 | 36 | } |
| 37 | 37 | } |