GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( f1b7d1...1bdbac )
by Carlos
03:08
created
src/ReceitaFederal/Services/Portais/AN/Service.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,28 +22,28 @@
 block discarded – undo
22 22
 			'data'		=> [
23 23
 				'error' => 'body > table:nth-child(3) > tr:nth-child(2) > td > b > font',
24 24
 				'numero_inscricao'  => 'body > table:nth-child(3) > tr > td > table:nth-child(3) > tr > td:nth-child(1) > font:nth-child(3) > b:nth-child(1)',
25
-		        'classificacao'     => 'body > table:nth-child(3) > tr > td > table:nth-child(3) > tr > td:nth-child(1) > font:nth-child(3) > b:nth-child(3)',
26
-		        'data_abertura'     => 'body > table:nth-child(3) > tr > td > table:nth-child(3) > tr > td:nth-child(3) > font:nth-child(3) > b',
27
-		        'nome_empresarial'  => 'body > table:nth-child(3) > tr > td > table:nth-child(5) > tr > td > font:nth-child(3) > b',
28
-		        'nome_fantasia'     => 'body > table:nth-child(3) > tr > td > table:nth-child(7) > tr > td > font:nth-child(3) > b',
29
-		        'cnae_principal'    => 'body > table:nth-child(3) > tr > td > table:nth-child(9) > tr > td > font:nth-child(3) > b',
30
-		        'cnae_secundarios'  => ['body > table:nth-child(3) > tr > td > table:nth-child(11) > tr > td' => 'td > font > b'],
31
-		        'natureza_juridica' => 'body > table:nth-child(3) > tr > td > table:nth-child(13) > tr > td > font:nth-child(3) > b',
32
-		        'endereco'          => 'body > table:nth-child(3) > tr > td > table:nth-child(15) > tr > td:nth-child(1) > font:nth-child(3) > b',
33
-		        'numero'            => 'body > table:nth-child(3) > tr > td > table:nth-child(15) > tr > td:nth-child(3) > font:nth-child(3) > b',
34
-		        'complemento'       => 'body > table:nth-child(3) > tr > td > table:nth-child(15) > tr > td:nth-child(5) > font:nth-child(3) > b',
35
-		        'cep'               => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(1) > font:nth-child(3) > b',
36
-		        'distrito'          => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(3) > font:nth-child(3) > b',
37
-		        'municipio'         => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(5) > font:nth-child(3) > b',
38
-		        'uf'                => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(7) > font:nth-child(3) > b',
39
-		        'email'             => 'body > table:nth-child(3) > tr > td > table:nth-child(19) > tr > td:nth-child(1) > font:nth-child(3) > b',
40
-		        'telefone'          => 'body > table:nth-child(3) > tr > td > table:nth-child(19) > tr > td:nth-child(3) > font:nth-child(3) > b',
41
-		        'efr'               => 'body > table:nth-child(3) > tr > td > table:nth-child(21) > tr > td > font:nth-child(3) > b',
42
-		        'situacao'          => 'body > table:nth-child(3) > tr > td > table:nth-child(23) > tr > td:nth-child(1) > font:nth-child(3) > b',
43
-		        'data_situacao'     => 'body > table:nth-child(3) > tr > td > table:nth-child(23) > tr > td:nth-child(3) > font:nth-child(3) > b',
44
-		        'motivo_situacao'   => 'body > table:nth-child(3) > tr > td > table:nth-child(25) > tr > td:nth-child(3) > font:nth-child(3) > b',
45
-		        'situacao_especial' => 'body > table:nth-child(3) > tr > td > table:nth-child(27) > tr > td:nth-child(1) > font:nth-child(3) > b',
46
-		        'data_situacao_especial' => 'body > table:nth-child(3) > tr > td > table:nth-child(27) > tr > td:nth-child(3) > font:nth-child(3) > b'
25
+				'classificacao'     => 'body > table:nth-child(3) > tr > td > table:nth-child(3) > tr > td:nth-child(1) > font:nth-child(3) > b:nth-child(3)',
26
+				'data_abertura'     => 'body > table:nth-child(3) > tr > td > table:nth-child(3) > tr > td:nth-child(3) > font:nth-child(3) > b',
27
+				'nome_empresarial'  => 'body > table:nth-child(3) > tr > td > table:nth-child(5) > tr > td > font:nth-child(3) > b',
28
+				'nome_fantasia'     => 'body > table:nth-child(3) > tr > td > table:nth-child(7) > tr > td > font:nth-child(3) > b',
29
+				'cnae_principal'    => 'body > table:nth-child(3) > tr > td > table:nth-child(9) > tr > td > font:nth-child(3) > b',
30
+				'cnae_secundarios'  => ['body > table:nth-child(3) > tr > td > table:nth-child(11) > tr > td' => 'td > font > b'],
31
+				'natureza_juridica' => 'body > table:nth-child(3) > tr > td > table:nth-child(13) > tr > td > font:nth-child(3) > b',
32
+				'endereco'          => 'body > table:nth-child(3) > tr > td > table:nth-child(15) > tr > td:nth-child(1) > font:nth-child(3) > b',
33
+				'numero'            => 'body > table:nth-child(3) > tr > td > table:nth-child(15) > tr > td:nth-child(3) > font:nth-child(3) > b',
34
+				'complemento'       => 'body > table:nth-child(3) > tr > td > table:nth-child(15) > tr > td:nth-child(5) > font:nth-child(3) > b',
35
+				'cep'               => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(1) > font:nth-child(3) > b',
36
+				'distrito'          => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(3) > font:nth-child(3) > b',
37
+				'municipio'         => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(5) > font:nth-child(3) > b',
38
+				'uf'                => 'body > table:nth-child(3) > tr > td > table:nth-child(17) > tr > td:nth-child(7) > font:nth-child(3) > b',
39
+				'email'             => 'body > table:nth-child(3) > tr > td > table:nth-child(19) > tr > td:nth-child(1) > font:nth-child(3) > b',
40
+				'telefone'          => 'body > table:nth-child(3) > tr > td > table:nth-child(19) > tr > td:nth-child(3) > font:nth-child(3) > b',
41
+				'efr'               => 'body > table:nth-child(3) > tr > td > table:nth-child(21) > tr > td > font:nth-child(3) > b',
42
+				'situacao'          => 'body > table:nth-child(3) > tr > td > table:nth-child(23) > tr > td:nth-child(1) > font:nth-child(3) > b',
43
+				'data_situacao'     => 'body > table:nth-child(3) > tr > td > table:nth-child(23) > tr > td:nth-child(3) > font:nth-child(3) > b',
44
+				'motivo_situacao'   => 'body > table:nth-child(3) > tr > td > table:nth-child(25) > tr > td:nth-child(3) > font:nth-child(3) > b',
45
+				'situacao_especial' => 'body > table:nth-child(3) > tr > td > table:nth-child(27) > tr > td:nth-child(1) > font:nth-child(3) > b',
46
+				'data_situacao_especial' => 'body > table:nth-child(3) > tr > td > table:nth-child(27) > tr > td:nth-child(3) > font:nth-child(3) > b'
47 47
 			]
48 48
 		],
49 49
 		'headers' => [
Please login to merge, or discard this patch.
src/ReceitaFederal/Services/Portais/AN/Crawler.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -12,99 +12,99 @@
 block discarded – undo
12 12
 class Crawler extends BaseCrawler implements CrawlerInterface
13 13
 {
14 14
 
15
-    /**
16
-     * [$selectors description]
17
-     * @var [type]
18
-     */
19
-    private $selectors = [];
15
+	/**
16
+	 * [$selectors description]
17
+	 * @var [type]
18
+	 */
19
+	private $selectors = [];
20 20
 
21
-    /**
22
-     * [__construct description]
23
-     * @param [type] $html      [description]
24
-     * @param array  $selectors [description]
25
-     */
26
-    public function __construct($html, $selectors)
27
-    {
28
-        $this->selectors = $selectors;
21
+	/**
22
+	 * [__construct description]
23
+	 * @param [type] $html      [description]
24
+	 * @param array  $selectors [description]
25
+	 */
26
+	public function __construct($html, $selectors)
27
+	{
28
+		$this->selectors = $selectors;
29 29
 
30
-        parent::__construct($html);
31
-    }
30
+		parent::__construct($html);
31
+	}
32 32
 
33
-    /**
34
-     * Verifica antes de fazer o crawler se possui erros
35
-     * na requisição
36
-     * @return boolean 
37
-     */
38
-    public function hasError()
39
-    {
40
-        if(count( $this->selectors) == 0) {
41
-            throw new NoSelectorsConfigured("NoSelectorsConfigured", 1);
42
-        }
33
+	/**
34
+	 * Verifica antes de fazer o crawler se possui erros
35
+	 * na requisição
36
+	 * @return boolean 
37
+	 */
38
+	public function hasError()
39
+	{
40
+		if(count( $this->selectors) == 0) {
41
+			throw new NoSelectorsConfigured("NoSelectorsConfigured", 1);
42
+		}
43 43
 
44
-        // verifica se a página seguida na requisição 
45
-        // é página de erro da receita federal
46
-        $node = $this->filter($this->selectors['error']);
44
+		// verifica se a página seguida na requisição 
45
+		// é página de erro da receita federal
46
+		$node = $this->filter($this->selectors['error']);
47 47
 
48
-        if($node->count()){
49
-             throw new ErrorFoundData( $this->clearString($node->text()), 1);
50
-        }
48
+		if($node->count()){
49
+			 throw new ErrorFoundData( $this->clearString($node->text()), 1);
50
+		}
51 51
         
52
-        // CNPJ informado é válido?
53
-        if($this->filter('#imgCaptcha')->count()){
54
-            throw new InvalidCaptcha('Captcha inválido', 99);
55
-        }
56
-    }
52
+		// CNPJ informado é válido?
53
+		if($this->filter('#imgCaptcha')->count()){
54
+			throw new InvalidCaptcha('Captcha inválido', 99);
55
+		}
56
+	}
57 57
 
58
-    /**
59
-     * Extrai informações do HTML através do DOM
60
-     *
61
-     * @return array
62
-     */
63
-    public function scraping()
64
-    {
65
-        $scrapped = [];
58
+	/**
59
+	 * Extrai informações do HTML através do DOM
60
+	 *
61
+	 * @return array
62
+	 */
63
+	public function scraping()
64
+	{
65
+		$scrapped = [];
66 66
 
67
-        $this->hasError();
67
+		$this->hasError();
68 68
 
69
-        foreach ($this->selectors as $name => $selector) {
70
-            if(is_string($selector)){
71
-                $node = $this->scrap($selector);
69
+		foreach ($this->selectors as $name => $selector) {
70
+			if(is_string($selector)){
71
+				$node = $this->scrap($selector);
72 72
 
73
-                if($node->count()){
74
-                    $scrapped[$name] = $this->clearString($node->text());
75
-                }
76
-            }elseif(is_array($selector)){
77
-                foreach ($selector as $selector => $repeat) {
78
-                    $node = $this->scrap($selector);
79
-                    if($node->count()){
80
-                        foreach ($node->filter($repeat) as $loop)
81
-                        {
82
-                            $scrapped[$name][] = $this->clearString($loop->nodeValue);
83
-                        }
84
-                    }
85
-                }
86
-            }
87
-        }
73
+				if($node->count()){
74
+					$scrapped[$name] = $this->clearString($node->text());
75
+				}
76
+			}elseif(is_array($selector)){
77
+				foreach ($selector as $selector => $repeat) {
78
+					$node = $this->scrap($selector);
79
+					if($node->count()){
80
+						foreach ($node->filter($repeat) as $loop)
81
+						{
82
+							$scrapped[$name][] = $this->clearString($loop->nodeValue);
83
+						}
84
+					}
85
+				}
86
+			}
87
+		}
88 88
 
89
-        return $scrapped;
90
-    }
89
+		return $scrapped;
90
+	}
91 91
 
92
-    /**
93
-     * Limpa o valor repassado
94
-     * @param  string $string
95
-     * @return string
96
-     */
97
-    public function clearString($string)
98
-    {
99
-        return trim(preg_replace(['/[\s]+/mu'], ' ', $string));
100
-    }
92
+	/**
93
+	 * Limpa o valor repassado
94
+	 * @param  string $string
95
+	 * @return string
96
+	 */
97
+	public function clearString($string)
98
+	{
99
+		return trim(preg_replace(['/[\s]+/mu'], ' ', $string));
100
+	}
101 101
 
102
-    /**
103
-     * Filtra selector no crawler
104
-     */
105
-    public function scrap($selector)
106
-    {
107
-        $node = $this->filter($selector);
108
-        return $node;
109
-    }
102
+	/**
103
+	 * Filtra selector no crawler
104
+	 */
105
+	public function scrap($selector)
106
+	{
107
+		$node = $this->filter($selector);
108
+		return $node;
109
+	}
110 110
 }
111 111
\ No newline at end of file
Please login to merge, or discard this patch.
src/ReceitaFederal/Services/Portais/AN/Search.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
 		$this->configurations = $configurations;
72 72
 
73 73
 		// instancia o client http
74
-        $this->client = new ClientHttp();
74
+		$this->client = new ClientHttp();
75 75
 
76
-        // Executa um request para URL do serviço, retornando o cookie da requisição primária
77
-        $this->instanceResponse = $this->client->request('GET', $this->configurations['home']);
76
+		// Executa um request para URL do serviço, retornando o cookie da requisição primária
77
+		$this->instanceResponse = $this->client->request('GET', $this->configurations['home']);
78 78
 
79
-        // Captura o cookie da requisição, será usuado posteriormente
80
-        $this->cookie = $this->client->cookie();
79
+		// Captura o cookie da requisição, será usuado posteriormente
80
+		$this->cookie = $this->client->cookie();
81 81
 
82 82
 		return $this;
83 83
 	}
@@ -104,57 +104,57 @@  discard block
 block discarded – undo
104 104
 		$this->hasRequested();
105 105
 
106 106
 		// Inicia instancia do cURL
107
-        $curl = new Curl;
108
-
109
-        // Inicia uma requisição para capturar a imagem do captcha
110
-        // informando cookie da requisição passada e os headers
111
-        //
112
-        // to-do: implementar guzzlehttp?
113
-        // ele é melhor que o curl? ou mais organizado?
114
-        $curl->init($this->configurations['captcha']);
115
-
116
-        // headers da requisição
117
-        $curl->options([
118
-                        CURLOPT_COOKIEJAR => 'cookiejar',
119
-                        CURLOPT_HTTPHEADER => array(
120
-                            "Pragma: no-cache",
121
-                            "Origin: " . $this->configurations['base'],
122
-                            "Host: ". array_get($this->configurations, 'headers.Host'),
123
-                            "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
124
-                            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
125
-                            "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
126
-                            "Accept-Encoding: gzip, deflate",
127
-                            "Referer: " . $this->configurations['home'],
128
-                            "Cookie: flag=1; ". $this->cookie,
129
-                            "Connection: keep-alive"
130
-                        ),
131
-                        CURLOPT_RETURNTRANSFER => true,
132
-                        CURLOPT_FOLLOWLOCATION => 1,
133
-                        CURLOPT_BINARYTRANSFER => TRUE,
134
-                        CURLOPT_CONNECTTIMEOUT => 10,
135
-                        CURLOPT_TIMEOUT => 10,
136
-                ]);
137
-
138
-        // executa o curl, logo após fechando a conexão
139
-        $curl->exec();
140
-        $curl->close();
141
-
142
-        // captura do retorno do curl
143
-        // o esperado deverá ser o HTML da imagem
144
-        $this->captcha = $curl->response();
145
-
146
-        // é uma imagem o retorno?
147
-        if(@imagecreatefromstring($this->captcha) == false)
148
-        {
149
-            throw new NoCaptchaResponse('Não foi possível capturar o captcha');
150
-        }
151
-
152
-        // constroe o base64 da imagem para o usuário digitar
153
-        // to-do: um serviço automatizado para decifrar o captcha?
154
-        // talvez deathbycaptcha?
155
-        $this->captchaImage = 'data:image/png;base64,' . base64_encode($this->captcha);
156
-
157
-        return $this->captchaImage;
107
+		$curl = new Curl;
108
+
109
+		// Inicia uma requisição para capturar a imagem do captcha
110
+		// informando cookie da requisição passada e os headers
111
+		//
112
+		// to-do: implementar guzzlehttp?
113
+		// ele é melhor que o curl? ou mais organizado?
114
+		$curl->init($this->configurations['captcha']);
115
+
116
+		// headers da requisição
117
+		$curl->options([
118
+						CURLOPT_COOKIEJAR => 'cookiejar',
119
+						CURLOPT_HTTPHEADER => array(
120
+							"Pragma: no-cache",
121
+							"Origin: " . $this->configurations['base'],
122
+							"Host: ". array_get($this->configurations, 'headers.Host'),
123
+							"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
124
+							"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
125
+							"Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
126
+							"Accept-Encoding: gzip, deflate",
127
+							"Referer: " . $this->configurations['home'],
128
+							"Cookie: flag=1; ". $this->cookie,
129
+							"Connection: keep-alive"
130
+						),
131
+						CURLOPT_RETURNTRANSFER => true,
132
+						CURLOPT_FOLLOWLOCATION => 1,
133
+						CURLOPT_BINARYTRANSFER => TRUE,
134
+						CURLOPT_CONNECTTIMEOUT => 10,
135
+						CURLOPT_TIMEOUT => 10,
136
+				]);
137
+
138
+		// executa o curl, logo após fechando a conexão
139
+		$curl->exec();
140
+		$curl->close();
141
+
142
+		// captura do retorno do curl
143
+		// o esperado deverá ser o HTML da imagem
144
+		$this->captcha = $curl->response();
145
+
146
+		// é uma imagem o retorno?
147
+		if(@imagecreatefromstring($this->captcha) == false)
148
+		{
149
+			throw new NoCaptchaResponse('Não foi possível capturar o captcha');
150
+		}
151
+
152
+		// constroe o base64 da imagem para o usuário digitar
153
+		// to-do: um serviço automatizado para decifrar o captcha?
154
+		// talvez deathbycaptcha?
155
+		$this->captchaImage = 'data:image/png;base64,' . base64_encode($this->captcha);
156
+
157
+		return $this->captchaImage;
158 158
 	}
159 159
 
160 160
 	/**
@@ -196,59 +196,59 @@  discard block
 block discarded – undo
196 196
 	public function getData($document, $cookie, $captcha, $params, $configurations)
197 197
 	{
198 198
 		// prepara o form
199
-        $postParams = [
200
-            'origem' => 'comprovante',
201
-            'cnpj' => $document, // apenas números
202
-            'txtTexto_captcha_serpro_gov_br' => $captcha,
203
-            'submit1' => 'Consultar',
204
-            'search_type' => 'cnpj'
205
-        ];
206
-
207
-        $postParams = array_merge($postParams, $params);
208
-
209
-        // inicia o cURL
210
-        $curl = new Curl;
211
-
212
-        // vamos registrar qual serviço será consultado
213
-        $curl->init($configurations['data']);
214
-
215
-        // define os headers para requisição curl.
216
-        $curl->options(
217
-            array(
218
-            	 CURLOPT_HTTPHEADER => array(
219
-                    "Pragma: no-cache",
220
-                    "Origin: " . $this->configurations['base'],
221
-                    "Host: ". array_get($configurations, 'headers.Host'),
222
-                    "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
223
-                    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
224
-                    "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
225
-                    "Accept-Encoding: gzip, deflate",
226
-                    "Referer: " . $this->configurations['home'] .'?cnpj='. $document,
227
-                    "Cookie: flag=1; ". $cookie,
228
-                    "Connection: keep-alive"
229
-                ),
230
-                CURLOPT_RETURNTRANSFER  => 1,
231
-                CURLOPT_BINARYTRANSFER => 1,
232
-                CURLOPT_FOLLOWLOCATION => 1,
233
-            )
234
-        );
235
-
236
-        // efetua a chamada passando os parametros de form
237
-        $curl->post($postParams);
238
-        $curl->exec();
239
-
240
-        // completa a chamda
241
-        $curl->close();
242
-
243
-        // vamos capturar retorno, que deverá ser o HTML para scrapping
244
-        $html = $curl->response();
245
-
246
-        if(empty($html)) {
247
-            throw new NoServiceResponse('No response from service', 99);
248
-        }
249
-
250
-        $crawler = new Crawler($html, array_get($configurations, 'selectors.data'));
251
-
252
-        return $crawler;
199
+		$postParams = [
200
+			'origem' => 'comprovante',
201
+			'cnpj' => $document, // apenas números
202
+			'txtTexto_captcha_serpro_gov_br' => $captcha,
203
+			'submit1' => 'Consultar',
204
+			'search_type' => 'cnpj'
205
+		];
206
+
207
+		$postParams = array_merge($postParams, $params);
208
+
209
+		// inicia o cURL
210
+		$curl = new Curl;
211
+
212
+		// vamos registrar qual serviço será consultado
213
+		$curl->init($configurations['data']);
214
+
215
+		// define os headers para requisição curl.
216
+		$curl->options(
217
+			array(
218
+				 CURLOPT_HTTPHEADER => array(
219
+					"Pragma: no-cache",
220
+					"Origin: " . $this->configurations['base'],
221
+					"Host: ". array_get($configurations, 'headers.Host'),
222
+					"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
223
+					"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
224
+					"Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
225
+					"Accept-Encoding: gzip, deflate",
226
+					"Referer: " . $this->configurations['home'] .'?cnpj='. $document,
227
+					"Cookie: flag=1; ". $cookie,
228
+					"Connection: keep-alive"
229
+				),
230
+				CURLOPT_RETURNTRANSFER  => 1,
231
+				CURLOPT_BINARYTRANSFER => 1,
232
+				CURLOPT_FOLLOWLOCATION => 1,
233
+			)
234
+		);
235
+
236
+		// efetua a chamada passando os parametros de form
237
+		$curl->post($postParams);
238
+		$curl->exec();
239
+
240
+		// completa a chamda
241
+		$curl->close();
242
+
243
+		// vamos capturar retorno, que deverá ser o HTML para scrapping
244
+		$html = $curl->response();
245
+
246
+		if(empty($html)) {
247
+			throw new NoServiceResponse('No response from service', 99);
248
+		}
249
+
250
+		$crawler = new Crawler($html, array_get($configurations, 'selectors.data'));
251
+
252
+		return $crawler;
253 253
 	}
254 254
 }
255 255
\ No newline at end of file
Please login to merge, or discard this patch.
src/Sintegra/Services/Portais/SP/Service.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -23,24 +23,24 @@
 block discarded – undo
23 23
 			'data'		=> [
24 24
 				'error' => 'body > center:nth-child(8) > table > tr > td > font > b',
25 25
 				'inscricao_estadual'  => 'body > center:nth-child(9) > table > tr > td:nth-child(4) > font',
26
-		        'razao_social' => 'body > center:nth-child(10) > table > tr > td:nth-child(2) > font',
27
-		        'logradouro' => 'body > center:nth-child(13) > table > tr > td:nth-child(2) > font',
28
-		        'numero'    => 'body > center:nth-child(14) > table > tr > td:nth-child(2) > font',
29
-		        'complemento' => 'body > center:nth-child(14) > table > tr > td:nth-child(4) > font',
30
-		        'bairro'    => 'body > center:nth-child(15) > table > tr > td:nth-child(2) > font',
31
-		        'municipio' => 'body > center:nth-child(16) > table > tr > td:nth-child(2) > font',
32
-		        'uf'        => 'body > center:nth-child(16) > table > tr > td:nth-child(4) > font',
33
-		        'cep'  => 'body > center:nth-child(17) > table > tr > td:nth-child(2) > font',
34
-		        'atividade_economica' => 'body > center:nth-child(20) > table > tr > td:nth-child(2) > font',
35
-		        'situacao'  => 'body > center:nth-child(21) > table > tr > td:nth-child(2) > font',
36
-		        'situacao2'  => 'body > center:nth-child(21) > table > tr > td:nth-child(3) > font',
37
-		        'data_situacao' => 'body > center:nth-child(22) > table > tr > td:nth-child(2) > font',
38
-		        'regime'    => 'body > center:nth-child(23) > table > tr > td:nth-child(2) > font',
39
-		        'data_emissor_nfe'  => 'body > center:nth-child(24) > table > tr > td:nth-child(2) > font',
40
-		        'indicator_obrigatoriedade_nfe' => 'body > center:nth-child(25) > table > tr > td:nth-child(2) > font',
41
-		        'data_inicio_obrigatoriedade_nfe'   => 'body > center:nth-child(26) > table > tr > td:nth-child(2) > font',
42
-		        'consulta'  => 'body > center:nth-child(28) > table > tr:nth-child(2) > td:nth-child(2) > font > b',
43
-		        'observacoes'   => 'body > center:nth-child(30) > table > tr > td > font:nth-child(1)',
26
+				'razao_social' => 'body > center:nth-child(10) > table > tr > td:nth-child(2) > font',
27
+				'logradouro' => 'body > center:nth-child(13) > table > tr > td:nth-child(2) > font',
28
+				'numero'    => 'body > center:nth-child(14) > table > tr > td:nth-child(2) > font',
29
+				'complemento' => 'body > center:nth-child(14) > table > tr > td:nth-child(4) > font',
30
+				'bairro'    => 'body > center:nth-child(15) > table > tr > td:nth-child(2) > font',
31
+				'municipio' => 'body > center:nth-child(16) > table > tr > td:nth-child(2) > font',
32
+				'uf'        => 'body > center:nth-child(16) > table > tr > td:nth-child(4) > font',
33
+				'cep'  => 'body > center:nth-child(17) > table > tr > td:nth-child(2) > font',
34
+				'atividade_economica' => 'body > center:nth-child(20) > table > tr > td:nth-child(2) > font',
35
+				'situacao'  => 'body > center:nth-child(21) > table > tr > td:nth-child(2) > font',
36
+				'situacao2'  => 'body > center:nth-child(21) > table > tr > td:nth-child(3) > font',
37
+				'data_situacao' => 'body > center:nth-child(22) > table > tr > td:nth-child(2) > font',
38
+				'regime'    => 'body > center:nth-child(23) > table > tr > td:nth-child(2) > font',
39
+				'data_emissor_nfe'  => 'body > center:nth-child(24) > table > tr > td:nth-child(2) > font',
40
+				'indicator_obrigatoriedade_nfe' => 'body > center:nth-child(25) > table > tr > td:nth-child(2) > font',
41
+				'data_inicio_obrigatoriedade_nfe'   => 'body > center:nth-child(26) > table > tr > td:nth-child(2) > font',
42
+				'consulta'  => 'body > center:nth-child(28) > table > tr:nth-child(2) > td:nth-child(2) > font > b',
43
+				'observacoes'   => 'body > center:nth-child(30) > table > tr > td > font:nth-child(1)',
44 44
 			]
45 45
 		],
46 46
 		'headers' => [
Please login to merge, or discard this patch.
src/Sintegra/Services/Portais/SP/Crawler.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -11,89 +11,89 @@
 block discarded – undo
11 11
 class Crawler extends BaseCrawler implements CrawlerInterface
12 12
 {
13 13
 
14
-    /**
15
-     * [$selectors description]
16
-     * @var [type]
17
-     */
18
-    private $selectors = [];
14
+	/**
15
+	 * [$selectors description]
16
+	 * @var [type]
17
+	 */
18
+	private $selectors = [];
19 19
 
20
-    /**
21
-     * [__construct description]
22
-     * @param [type] $html      [description]
23
-     * @param array  $selectors [description]
24
-     */
25
-    public function __construct($html, $selectors)
26
-    {
27
-        $this->selectors = $selectors;
20
+	/**
21
+	 * [__construct description]
22
+	 * @param [type] $html      [description]
23
+	 * @param array  $selectors [description]
24
+	 */
25
+	public function __construct($html, $selectors)
26
+	{
27
+		$this->selectors = $selectors;
28 28
 
29
-        parent::__construct($html);
30
-    }
29
+		parent::__construct($html);
30
+	}
31 31
 
32
-    /**
33
-     * Verifica antes de fazer o crawler se possui erros
34
-     * na requisição
35
-     * @return boolean 
36
-     */
37
-    public function hasError()
38
-    {
39
-        $node = $this->scrap($this->selectors['razao_social']);
32
+	/**
33
+	 * Verifica antes de fazer o crawler se possui erros
34
+	 * na requisição
35
+	 * @return boolean 
36
+	 */
37
+	public function hasError()
38
+	{
39
+		$node = $this->scrap($this->selectors['razao_social']);
40 40
 
41
-        if(!$node->count())
42
-        {
43
-            throw new ErrorFoundData($this->clearString($this->scrap($this->selectors['error'])->text()), 1);
44
-        }
45
-    }
41
+		if(!$node->count())
42
+		{
43
+			throw new ErrorFoundData($this->clearString($this->scrap($this->selectors['error'])->text()), 1);
44
+		}
45
+	}
46 46
 
47
-    /**
48
-     * Extrai informações do HTML através do DOM
49
-     *
50
-     * @return array
51
-     */
52
-    public function scraping()
53
-    {
54
-        $scrapped = [];
47
+	/**
48
+	 * Extrai informações do HTML através do DOM
49
+	 *
50
+	 * @return array
51
+	 */
52
+	public function scraping()
53
+	{
54
+		$scrapped = [];
55 55
 
56
-        $this->hasError();
56
+		$this->hasError();
57 57
 
58
-        foreach ($this->selectors as $name => $selector) {
59
-            if(is_string($selector)){
60
-                $node = $this->scrap($selector);
58
+		foreach ($this->selectors as $name => $selector) {
59
+			if(is_string($selector)){
60
+				$node = $this->scrap($selector);
61 61
 
62
-                if($node->count()){
63
-                    $scrapped[$name] = $this->clearString($node->text());
64
-                }
65
-            }elseif(is_array($selector)){
66
-                foreach ($selector as $selector => $repeat) {
67
-                    $node = $this->scrap($selector);
68
-                    if($node->count()){
69
-                        foreach ($node->filter($repeat) as $loop)
70
-                        {
71
-                            $scrapped[$name][] = $this->clearString($loop->nodeValue);
72
-                        }
73
-                    }
74
-                }
75
-            }
76
-        }
62
+				if($node->count()){
63
+					$scrapped[$name] = $this->clearString($node->text());
64
+				}
65
+			}elseif(is_array($selector)){
66
+				foreach ($selector as $selector => $repeat) {
67
+					$node = $this->scrap($selector);
68
+					if($node->count()){
69
+						foreach ($node->filter($repeat) as $loop)
70
+						{
71
+							$scrapped[$name][] = $this->clearString($loop->nodeValue);
72
+						}
73
+					}
74
+				}
75
+			}
76
+		}
77 77
 
78
-        return $scrapped;
79
-    }
78
+		return $scrapped;
79
+	}
80 80
 
81
-    /**
82
-     * Limpa o valor repassado
83
-     * @param  string $string
84
-     * @return string
85
-     */
86
-    public function clearString($string)
87
-    {
88
-        return trim(preg_replace(['/[\s]+/mu'], ' ', $string));
89
-    }
81
+	/**
82
+	 * Limpa o valor repassado
83
+	 * @param  string $string
84
+	 * @return string
85
+	 */
86
+	public function clearString($string)
87
+	{
88
+		return trim(preg_replace(['/[\s]+/mu'], ' ', $string));
89
+	}
90 90
 
91
-    /**
92
-     * Filtra selector no crawler
93
-     */
94
-    public function scrap($selector)
95
-    {
96
-        $node = $this->filter($selector);
97
-        return $node;
98
-    }
91
+	/**
92
+	 * Filtra selector no crawler
93
+	 */
94
+	public function scrap($selector)
95
+	{
96
+		$node = $this->filter($selector);
97
+		return $node;
98
+	}
99 99
 }
100 100
\ No newline at end of file
Please login to merge, or discard this patch.
src/Sintegra/Services/Portais/SP/Search.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 		$this->configurations = $configurations;
70 70
 
71 71
 		// instancia o client http
72
-        $this->client = new ClientHttp();
72
+		$this->client = new ClientHttp();
73 73
 
74
-        // Executa um request para URL do serviço, retornando o cookie da requisição primária
75
-        $this->instanceResponse = $this->client->request('GET', $this->configurations['home']);
74
+		// Executa um request para URL do serviço, retornando o cookie da requisição primária
75
+		$this->instanceResponse = $this->client->request('GET', $this->configurations['home']);
76 76
 
77
-        // Captura o cookie da requisição, será usuado posteriormente
78
-        $this->cookie = $this->client->cookie();
77
+		// Captura o cookie da requisição, será usuado posteriormente
78
+		$this->cookie = $this->client->cookie();
79 79
 
80 80
 		return $this;
81 81
 	}
@@ -109,68 +109,68 @@  discard block
 block discarded – undo
109 109
 			throw new ImageNotFound("Impossible to crawler image from response", 1);
110 110
 		}
111 111
 
112
-        $paramBot = $this->instanceResponse->filter(
113
-        				array_get($this->configurations, 'selectors.paramBot')
114
-        			);
112
+		$paramBot = $this->instanceResponse->filter(
113
+						array_get($this->configurations, 'selectors.paramBot')
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
 
120 120
 		// Inicia instancia do cURL
121
-        $curl = new Curl;
122
-
123
-        // Inicia uma requisição para capturar a imagem do captcha
124
-        // informando cookie da requisição passada e os headers
125
-        //
126
-        // to-do: implementar guzzlehttp?
127
-        // ele é melhor que o curl? ou mais organizado?
128
-        $curl->init($this->configurations['base'] . $imageSrc->attr('src'));
129
-
130
-        $this->params['parambot'] = trim($paramBot->attr('value'));
131
-
132
-        // headers da requisição
133
-        $curl->options([
134
-                        CURLOPT_COOKIEJAR => 'cookiejar',
135
-                        CURLOPT_HTTPHEADER => array(
136
-                            "Pragma: no-cache",
137
-                            "Origin: " . $this->configurations['base'],
138
-                            "Host: ". array_get($this->configurations, 'headers.Host'),
139
-                            "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
140
-                            "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
141
-                            "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
142
-                            "Accept-Encoding: gzip, deflate",
143
-                            "Referer: " . $this->configurations['captcha'],
144
-                            "Cookie: flag=1; ". $this->cookie,
145
-                            "Connection: keep-alive"
146
-                        ),
147
-                        CURLOPT_RETURNTRANSFER => true,
148
-                        CURLOPT_FOLLOWLOCATION => 1,
149
-                        CURLOPT_BINARYTRANSFER => TRUE,
150
-                        CURLOPT_CONNECTTIMEOUT => 10,
151
-                        CURLOPT_TIMEOUT => 10,
152
-                ]);
153
-
154
-        // executa o curl, logo após fechando a conexão
155
-        $curl->exec();
156
-        $curl->close();
157
-
158
-        // captura do retorno do curl
159
-        // o esperado deverá ser o HTML da imagem
160
-        $this->captcha = $curl->response();
161
-
162
-        // é uma imagem o retorno?
163
-        if(@imagecreatefromstring($this->captcha) == false)
164
-        {
165
-            throw new NoCaptchaResponse('Não foi possível capturar o captcha');
166
-        }
167
-
168
-        // constroe o base64 da imagem para o usuário digitar
169
-        // to-do: um serviço automatizado para decifrar o captcha?
170
-        // talvez deathbycaptcha?
171
-        $this->captchaImage = 'data:image/png;base64,' . base64_encode($this->captcha);
172
-
173
-        return $this->captchaImage;
121
+		$curl = new Curl;
122
+
123
+		// Inicia uma requisição para capturar a imagem do captcha
124
+		// informando cookie da requisição passada e os headers
125
+		//
126
+		// to-do: implementar guzzlehttp?
127
+		// ele é melhor que o curl? ou mais organizado?
128
+		$curl->init($this->configurations['base'] . $imageSrc->attr('src'));
129
+
130
+		$this->params['parambot'] = trim($paramBot->attr('value'));
131
+
132
+		// headers da requisição
133
+		$curl->options([
134
+						CURLOPT_COOKIEJAR => 'cookiejar',
135
+						CURLOPT_HTTPHEADER => array(
136
+							"Pragma: no-cache",
137
+							"Origin: " . $this->configurations['base'],
138
+							"Host: ". array_get($this->configurations, 'headers.Host'),
139
+							"User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:32.0) Gecko/20100101 Firefox/32.0",
140
+							"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
141
+							"Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.5,en;q=0.3",
142
+							"Accept-Encoding: gzip, deflate",
143
+							"Referer: " . $this->configurations['captcha'],
144
+							"Cookie: flag=1; ". $this->cookie,
145
+							"Connection: keep-alive"
146
+						),
147
+						CURLOPT_RETURNTRANSFER => true,
148
+						CURLOPT_FOLLOWLOCATION => 1,
149
+						CURLOPT_BINARYTRANSFER => TRUE,
150
+						CURLOPT_CONNECTTIMEOUT => 10,
151
+						CURLOPT_TIMEOUT => 10,
152
+				]);
153
+
154
+		// executa o curl, logo após fechando a conexão
155
+		$curl->exec();
156
+		$curl->close();
157
+
158
+		// captura do retorno do curl
159
+		// o esperado deverá ser o HTML da imagem
160
+		$this->captcha = $curl->response();
161
+
162
+		// é uma imagem o retorno?
163
+		if(@imagecreatefromstring($this->captcha) == false)
164
+		{
165
+			throw new NoCaptchaResponse('Não foi possível capturar o captcha');
166
+		}
167
+
168
+		// constroe o base64 da imagem para o usuário digitar
169
+		// to-do: um serviço automatizado para decifrar o captcha?
170
+		// talvez deathbycaptcha?
171
+		$this->captchaImage = 'data:image/png;base64,' . base64_encode($this->captcha);
172
+
173
+		return $this->captchaImage;
174 174
 	}
175 175
 
176 176
 	/**
@@ -212,58 +212,58 @@  discard block
 block discarded – undo
212 212
 	public function getData($document, $cookie, $captcha, $params, $configurations)
213 213
 	{
214 214
 		// prepara o form
215
-        $postParams = [
216
-            'cnpj' => $document, // apenas números
217
-            'Key' => $captcha,
218
-            'botao' => 'Consulta por CNPJ',
219
-            'hidFlag' => '1',
220
-            'ie' => '',
221
-            'servico' => 'cnpj',
222
-            'paramBot' => $params['parambot']
223
-        ];
224
-
225
-        // inicia o cURL
226
-        $curl = new Curl;
227
-
228
-        // vamos registrar qual serviço será consultado
229
-        $curl->init($configurations['data']);
230
-
231
-        // define os headers para requisição curl.
232
-        $curl->options(
233
-            array(
234
-                CURLOPT_HTTPHEADER => array(
235
-                    "Origin: http://pfeserv1.fazenda.sp.gov.br",
236
-                    "Host: pfeserv1.fazenda.sp.gov.br",
237
-                    "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36",
238
-                    "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
239
-                    "Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2",
240
-                    "Accept-Encoding: gzip, deflate",
241
-                    "Referer: http://pfeserv1.fazenda.sp.gov.br/sintegrapfe/consultaSintegraServlet",
242
-                    "Cookie: flag=1; ". $cookie,
243
-                    "Connection: keep-alive"
244
-                ),
245
-                CURLOPT_RETURNTRANSFER  => 1,
246
-                CURLOPT_BINARYTRANSFER => 1,
247
-                CURLOPT_FOLLOWLOCATION => 1,
248
-            )
249
-        );
250
-
251
-        // efetua a chamada passando os parametros de form
252
-        $curl->post($postParams);
253
-        $curl->exec();
254
-
255
-        // completa a chamda
256
-        $curl->close();
257
-
258
-        // vamos capturar retorno, que deverá ser o HTML para scrapping
259
-        $html = $curl->response();
260
-
261
-        if(empty($html)) {
262
-            throw new NoServiceResponse('No response from service', 99);
263
-        }
264
-
265
-        $crawler = new Crawler($html, array_get($configurations, 'selectors.data'));
266
-
267
-        return $crawler;
215
+		$postParams = [
216
+			'cnpj' => $document, // apenas números
217
+			'Key' => $captcha,
218
+			'botao' => 'Consulta por CNPJ',
219
+			'hidFlag' => '1',
220
+			'ie' => '',
221
+			'servico' => 'cnpj',
222
+			'paramBot' => $params['parambot']
223
+		];
224
+
225
+		// inicia o cURL
226
+		$curl = new Curl;
227
+
228
+		// vamos registrar qual serviço será consultado
229
+		$curl->init($configurations['data']);
230
+
231
+		// define os headers para requisição curl.
232
+		$curl->options(
233
+			array(
234
+				CURLOPT_HTTPHEADER => array(
235
+					"Origin: http://pfeserv1.fazenda.sp.gov.br",
236
+					"Host: pfeserv1.fazenda.sp.gov.br",
237
+					"User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/49.0.2623.108 Chrome/49.0.2623.108 Safari/537.36",
238
+					"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
239
+					"Accept-Language: pt-BR,pt;q=0.8,en-US;q=0.6,en;q=0.4,es;q=0.2",
240
+					"Accept-Encoding: gzip, deflate",
241
+					"Referer: http://pfeserv1.fazenda.sp.gov.br/sintegrapfe/consultaSintegraServlet",
242
+					"Cookie: flag=1; ". $cookie,
243
+					"Connection: keep-alive"
244
+				),
245
+				CURLOPT_RETURNTRANSFER  => 1,
246
+				CURLOPT_BINARYTRANSFER => 1,
247
+				CURLOPT_FOLLOWLOCATION => 1,
248
+			)
249
+		);
250
+
251
+		// efetua a chamada passando os parametros de form
252
+		$curl->post($postParams);
253
+		$curl->exec();
254
+
255
+		// completa a chamda
256
+		$curl->close();
257
+
258
+		// vamos capturar retorno, que deverá ser o HTML para scrapping
259
+		$html = $curl->response();
260
+
261
+		if(empty($html)) {
262
+			throw new NoServiceResponse('No response from service', 99);
263
+		}
264
+
265
+		$crawler = new Crawler($html, array_get($configurations, 'selectors.data'));
266
+
267
+		return $crawler;
268 268
 	}
269 269
 }
270 270
\ No newline at end of file
Please login to merge, or discard this patch.
src/Miscellany/ClientHttp.php 1 patch
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -8,64 +8,64 @@
 block discarded – undo
8 8
 */
9 9
 class ClientHttp extends BaseClient
10 10
 {
11
-    /**
12
-     * [$protocol description]
13
-     * @var [type]
14
-     */
15
-    protected $method;
11
+	/**
12
+	 * [$protocol description]
13
+	 * @var [type]
14
+	 */
15
+	protected $method;
16 16
 
17
-    /**
18
-     * [$url description]
19
-     * @var [type]
20
-     */
21
-    protected $url;
17
+	/**
18
+	 * [$url description]
19
+	 * @var [type]
20
+	 */
21
+	protected $url;
22 22
 
23
-    /**
24
-     * [$cookie description]
25
-     * @var [type]
26
-     */
27
-    protected $cookie;
23
+	/**
24
+	 * [$cookie description]
25
+	 * @var [type]
26
+	 */
27
+	protected $cookie;
28 28
 
29
-    /**
30
-     * [$response description]
31
-     * @var [type]
32
-     */
33
-    protected $response;
29
+	/**
30
+	 * [$response description]
31
+	 * @var [type]
32
+	 */
33
+	protected $response;
34 34
 
35
-    /**
36
-     * [request description]
37
-     * @param  string  $method        [description]
38
-     * @param  string  $url           [description]
39
-     * @param  array   $parameters    [description]
40
-     * @param  array   $files         [description]
41
-     * @param  array   $server        [description]
42
-     * @param  [type]  $content       [description]
43
-     * @param  boolean $changeHistory [description]
44
-     * @return @instance
45
-     */
46
-    public function request($method, $url, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true)
47
-    {
48
-        $this->method = $method;
49
-        $this->url = $url;
35
+	/**
36
+	 * [request description]
37
+	 * @param  string  $method        [description]
38
+	 * @param  string  $url           [description]
39
+	 * @param  array   $parameters    [description]
40
+	 * @param  array   $files         [description]
41
+	 * @param  array   $server        [description]
42
+	 * @param  [type]  $content       [description]
43
+	 * @param  boolean $changeHistory [description]
44
+	 * @return @instance
45
+	 */
46
+	public function request($method, $url, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true)
47
+	{
48
+		$this->method = $method;
49
+		$this->url = $url;
50 50
 
51
-        return parent::request($this->method, $this->url, $parameters, $files, $server, $content, $changeHistory);
52
-    }
51
+		return parent::request($this->method, $this->url, $parameters, $files, $server, $content, $changeHistory);
52
+	}
53 53
 
54
-    /**
55
-     * [headers description]
56
-     * @return [type] [description]
57
-     */
58
-    private function headers()
59
-    {
60
-        return $this->response->getHeaders();
61
-    }
54
+	/**
55
+	 * [headers description]
56
+	 * @return [type] [description]
57
+	 */
58
+	private function headers()
59
+	{
60
+		return $this->response->getHeaders();
61
+	}
62 62
 
63
-    /**
64
-     * [cookie description]
65
-     * @return [type] [description]
66
-     */
67
-    public function cookie()
68
-    {
69
-        return $this->headers()['Set-Cookie'][0];
70
-    }
63
+	/**
64
+	 * [cookie description]
65
+	 * @return [type] [description]
66
+	 */
67
+	public function cookie()
68
+	{
69
+		return $this->headers()['Set-Cookie'][0];
70
+	}
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
src/Miscellany/Curl.php 1 patch
Indentation   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -7,106 +7,106 @@
 block discarded – undo
7 7
 class Curl
8 8
 {
9 9
 
10
-    /**
11
-     * [$url description]
12
-     * @var [type]
13
-     */
14
-    private $url;
15
-
16
-    /**
17
-     * [$options description]
18
-     * @var [type]
19
-     */
20
-    private $options;
21
-
22
-    /**
23
-     * [$instance description]
24
-     * @var [type]
25
-     */
26
-    private $instance;
27
-
28
-    /**
29
-     * [$response description]
30
-     * @var [type]
31
-     */
32
-    private $response;
33
-
34
-    /**
35
-     * [init description]
36
-     * @return [type] [description]
37
-     */
38
-    public function init($url)
39
-    {
40
-        $this->instance = curl_init($url);
41
-
42
-        $this->url = $url;
43
-
44
-        return $this;
45
-    }
46
-
47
-    /**
48
-     * [options description]
49
-     * @param  array  $options [description]
50
-     * @return [type]          [description]
51
-     */
52
-    public function options(array $options)
53
-    {
54
-        $this->options = $options;
55
-
56
-        curl_setopt_array($this->instance, $this->options);
57
-
58
-        return $this;
59
-    }
60
-
61
-    /**
62
-     * [post description]
63
-     * @param  [type] $params [description]
64
-     * @return [type]         [description]
65
-     */
66
-    public function post(array $fields)
67
-    {
68
-        $this->option(CURLOPT_POST, count($fields));
69
-        $this->option(CURLOPT_POSTFIELDS, http_build_query($fields));
70
-
71
-        return $this;
72
-    }
73
-
74
-    /**
75
-     * Set option in cURL
76
-     * @param  mix $option 
77
-     * @param  mix $value 
78
-     */
79
-    public function option($option, $value)
80
-    {
81
-        curl_setopt($this->instance, $option, $value);
82
-    }
83
-
84
-    /**
85
-     * [exec description]
86
-     * @return [type] [description]
87
-     */
88
-    public function exec()
89
-    {
90
-        $this->response = curl_exec($this->instance);
91
-    }
92
-
93
-    /**
94
-     * [close description]
95
-     * @return [type] [description]
96
-     */
97
-    public function close()
98
-    {
99
-        curl_close($this->instance);
100
-
101
-        return $this;
102
-    }
103
-
104
-    /**
105
-     * [response description]
106
-     * @return [type] [description]
107
-     */
108
-    public function response()
109
-    {
110
-        return $this->response;
111
-    }
10
+	/**
11
+	 * [$url description]
12
+	 * @var [type]
13
+	 */
14
+	private $url;
15
+
16
+	/**
17
+	 * [$options description]
18
+	 * @var [type]
19
+	 */
20
+	private $options;
21
+
22
+	/**
23
+	 * [$instance description]
24
+	 * @var [type]
25
+	 */
26
+	private $instance;
27
+
28
+	/**
29
+	 * [$response description]
30
+	 * @var [type]
31
+	 */
32
+	private $response;
33
+
34
+	/**
35
+	 * [init description]
36
+	 * @return [type] [description]
37
+	 */
38
+	public function init($url)
39
+	{
40
+		$this->instance = curl_init($url);
41
+
42
+		$this->url = $url;
43
+
44
+		return $this;
45
+	}
46
+
47
+	/**
48
+	 * [options description]
49
+	 * @param  array  $options [description]
50
+	 * @return [type]          [description]
51
+	 */
52
+	public function options(array $options)
53
+	{
54
+		$this->options = $options;
55
+
56
+		curl_setopt_array($this->instance, $this->options);
57
+
58
+		return $this;
59
+	}
60
+
61
+	/**
62
+	 * [post description]
63
+	 * @param  [type] $params [description]
64
+	 * @return [type]         [description]
65
+	 */
66
+	public function post(array $fields)
67
+	{
68
+		$this->option(CURLOPT_POST, count($fields));
69
+		$this->option(CURLOPT_POSTFIELDS, http_build_query($fields));
70
+
71
+		return $this;
72
+	}
73
+
74
+	/**
75
+	 * Set option in cURL
76
+	 * @param  mix $option 
77
+	 * @param  mix $value 
78
+	 */
79
+	public function option($option, $value)
80
+	{
81
+		curl_setopt($this->instance, $option, $value);
82
+	}
83
+
84
+	/**
85
+	 * [exec description]
86
+	 * @return [type] [description]
87
+	 */
88
+	public function exec()
89
+	{
90
+		$this->response = curl_exec($this->instance);
91
+	}
92
+
93
+	/**
94
+	 * [close description]
95
+	 * @return [type] [description]
96
+	 */
97
+	public function close()
98
+	{
99
+		curl_close($this->instance);
100
+
101
+		return $this;
102
+	}
103
+
104
+	/**
105
+	 * [response description]
106
+	 * @return [type] [description]
107
+	 */
108
+	public function response()
109
+	{
110
+		return $this->response;
111
+	}
112 112
 }
113 113
\ No newline at end of file
Please login to merge, or discard this patch.