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.

ValidatorsClient::email()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
namespace NStack\Clients;
4
5
use NStack\Exceptions\FailedToParseException;
6
use NStack\Models\EmailValidation;
7
use NStack\Models\PhoneValidation;
8
9
/**
10
 * Class ValidatorsClient
11
 *
12
 * @package NStack\Clients
13
 * @author  Tiago Araujo <[email protected]>
14
 */
15
class ValidatorsClient extends NStackClient
16
{
17
    /** @var string */
18
    protected $path = 'validator';
19
20
    /**
21
     * email
22
     *
23
     * @param String $email
24
     * @return EmailValidation
25
     * @throws FailedToParseException
26
     * @author  Tiago Araujo <[email protected]>
27
     */
28 1
    public function email(String $email): EmailValidation
29
    {
30 1
        $response = $this->client->get($this->buildPath($this->path . '/email?email=' . $email));
31 1
        $contents = $response->getBody()->getContents();
32 1
        $data = json_decode($contents, true);
33
34 1
        return new EmailValidation($data);
35
    }
36
37
    /**
38
     * phone
39
     *
40
     * @param String       $phone
41
     * @param String|null  $fallbackCountryCode
42
     * @param Boolean|null $validateWithTwilio
43
     * @param String|null  $twilioType
44
     * @return PhoneValidation
45
     * @throws FailedToParseException
46
     * @author  Tiago Araujo <[email protected]>
47
     */
48 1
    public function phone(
49
        String $phone,
50
        String $fallbackCountryCode = null,
51
        bool $validateWithTwilio = null,
52
        String $twilioType = null
53
    ): PhoneValidation {
54 1
        $path = $this->buildPath($this->path . '/phone?phone=' . $phone);
55
56 1
        if ($fallbackCountryCode) {
57 1
            $path = $path . '&fallback_country_code=' . $fallbackCountryCode;
58
        }
59 1
        if ($validateWithTwilio) {
60 1
            $path = $path . '&twilio=' . $validateWithTwilio;
0 ignored issues
show
Bug introduced by
Are you sure $validateWithTwilio of type true can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

60
            $path = $path . '&twilio=' . /** @scrutinizer ignore-type */ $validateWithTwilio;
Loading history...
61
        }
62 1
        if ($twilioType) {
63 1
            $path = $path . '&twilio_type=' . $twilioType;
64
        }
65
66 1
        $response = $this->client->get($path);
67 1
        $contents = $response->getBody()->getContents();
68 1
        $data = json_decode($contents, true);
69
70 1
        return new PhoneValidation($data);
71
    }
72
}