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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 56
ccs 17
cts 17
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A phone() 0 23 4
A email() 0 7 1
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
}