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 ( f09d4b...05f0b0 )
by Carlos
03:53
created

Sintegra.php ➔ sintegra()   B

Complexity

Conditions 5
Paths 2

Size

Total Lines 25
Code Lines 10

Duplication

Lines 5
Ratio 20 %
Metric Value
cc 5
eloc 10
nc 2
nop 5
dl 5
loc 25
rs 8.439
1
<?php
2
if (!function_exists('sintegra'))
3
{
4
	/**
5
	 * Helper retorna informações do sintegra
6
	 * @param  integer $document CNPJ or IE
7
	 * @param  string $cookie   cookie request
8
	 * @param  string $captcha  Captcha resolvido
9
	 * @param  array $params   
10
	 * @return array
11
	 */
12
	function sintegra($portal = 'SP', $document = null, $cookie = null, $captcha = null, $params = null )
13
	{	
14
		/**
15
		 * Inicia a classe
16
		 * @var object \zServices\Sintegra\Services\Portais\{$portal}\Service
17
		 */
18
		$search = (new \zServices\Sintegra\Search)->service($portal);
19
20
		// Esta pesquisando por um documento?
21 View Code Duplication
		if($document && $cookie && captcha && $params) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $document of type integer|null is loosely compared to true; this is ambiguous if the integer can be zero. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For integer values, zero is a special case, in particular the following results might be unexpected:

0   == false // true
0   == null  // true
123 == false // false
123 == null  // false

// It is often better to use strict comparison
0 === false // false
0 === null  // false
Loading history...
Bug Best Practice introduced by
The expression $cookie of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
			$crawler = $search->data($document, $cookie, $captcha, $params);
23
24
			return $crawler->scraping();
0 ignored issues
show
Bug introduced by
The method scraping cannot be called on $crawler (of type array).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
25
		}
26
27
		// Se não retorna requisição inicial
28
		// com cookie e captcha
29
		$search->request();
30
31
		return  [
32
            'cookie' => $search->cookie(),
33
            'image'  => $search->captcha(),
34
            'paramBot' => $search->params()['parambot']
35
        ];
36
	}
37
}