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 ( 1e7288...618d26 )
by Carlos
19:48 queued 04:50
created

DeathByCaptcha::resolverV2()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
crap 6
1
<?php
2
3
namespace juniorb2ss\DeathByCaptcha;
4
5
use GuzzleHttp\Client as GuzzleClient;
6
use GuzzleHttp\ClientInterface;
7
use GuzzleHttp\Psr7\Response;
8
use juniorb2ss\DeathByCaptcha\Abstracts\HttpDeathByCaptchaAbstract;
9
use juniorb2ss\DeathByCaptcha\Interfaces\AccountInterface;
10
use juniorb2ss\DeathByCaptcha\Interfaces\DeathByCaptchaInterface;
11
use juniorb2ss\DeathByCaptcha\Interfaces\ReportInterface;
12
use juniorb2ss\DeathByCaptcha\Interfaces\ResolveInterface;
13
use juniorb2ss\DeathByCaptcha\Interfaces\StatusInterface;
14
use juniorb2ss\DeathByCaptcha\Services\AccountService;
15
use juniorb2ss\DeathByCaptcha\Services\ImageService;
16
use juniorb2ss\DeathByCaptcha\Services\ReportService;
17
use juniorb2ss\DeathByCaptcha\Services\ResolveService;
18
use juniorb2ss\DeathByCaptcha\Services\StatusService;
19
20
class DeathByCaptcha extends HttpDeathByCaptchaAbstract implements DeathByCaptchaInterface
21
{
22
    /**
23
     * URL do serviço
24
     */
25
    const API_URL = 'http://api.dbcapi.me/api/';
26
27
    /**
28
     * API Version
29
     */
30
    const API_VERSION = 'DBC/PHP v5';
31
32
    /**
33
     * Request DEFAULT TIMEOUT
34
     */
35
    const DEFAULT_TIMEOUT = 60;
36
37
    /**
38
     * @param string                $username
39
     * @param string                $password
40
     * @param ClientInterface|null  $client
0 ignored issues
show
Bug introduced by
There is no parameter named $client. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
41
     * @param AccountInterface|null $account
0 ignored issues
show
Bug introduced by
There is no parameter named $account. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
42
     * @param StatusInterface|null  $status
0 ignored issues
show
Bug introduced by
There is no parameter named $status. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
43
     */
44 81
    public function __construct(
45
        string $username,
46
        string $password
47
    ) {
48 81
        $this->username = $username;
0 ignored issues
show
Bug introduced by
The property username does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
49 81
        $this->password = $password;
0 ignored issues
show
Bug introduced by
The property password does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
50
51 81
        $this->client = new GuzzleClient;
0 ignored issues
show
Bug introduced by
The property client does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
52 81
        $this->account = new AccountService;
0 ignored issues
show
Bug introduced by
The property account does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
53 81
        $this->status = new StatusService;
0 ignored issues
show
Bug introduced by
The property status does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54 81
        $this->report = new ReportService;
0 ignored issues
show
Bug introduced by
The property report does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
55 81
        $this->resolve = new ResolveService;
0 ignored issues
show
Bug introduced by
The property resolve does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
56 81
    }
57
58 81
    public function setHttpClient(ClientInterface $client)
59
    {
60 81
        $this->client = $client;
61
62 81
        return $this;
63
    }
64
65 39
    public function account(): AccountInterface
66
    {
67 39
        $response = $this->accountRequest();
68
69 24
        return $this->account
70 24
                    ->setResponse($response);
71
    }
72
73 18
    public function status(): StatusInterface
74
    {
75 18
        $response = $this->statusRequest();
76
77 18
        return $this->status
78 18
                    ->setResponse($response);
79
    }
80
81 3
    public function report(int $id): ReportInterface
82
    {
83 3
        $response = $this->captchAsIncorrect($id);
84
85 3
        return $this->report
86 3
                    ->setResponse($response);
87
    }
88
89 21
    public function resolve($captcha): ResolveInterface
90
    {
91
        // If passed captcha id, retrieve captcha text
92 21
        if (is_int($captcha)) {
93 6
            $response = $this->retrieveCaptcha($captcha);
94
        } else {
95 15
            $image = ImageService::base64From($captcha);
96
97 12
            $response = $this->uploadCaptcha($image);
98
        }
99
100 6
        return $this->resolve
101 6
                    ->setResponse($response);
102
    }
103
104
    public function resolveV2(string $mix, string $url = null): ResolveInterface
105
    {
106
        if (is_null($url)) {
107
            $response = $this->retrieveCaptcha($mix);
108
        } else {
109
            $response = $this->sendReCaptchaV2($mix, $url);
110
        }
111
112
        return $this->resolve
113
                    ->setResponse($response);
114
    }
115
}
116