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.
Test Setup Failed
Push — master ( 9d889d...27a869 )
by Carlos
02:09
created

PhoneNumber::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the overtrue/easy-sms.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Overtrue\EasySms;
13
14
/**
15
 * Class PhoneNumberInterface.
16
 *
17
 * @author overtrue <[email protected]>
18
 */
19
class PhoneNumber implements \Overtrue\EasySms\Contracts\PhoneNumberInterface
20
{
21
    /**
22
     * @var int
23
     */
24
    protected $number;
25
26
    /**
27
     * @var int
28
     */
29
    protected $IDDCode;
30
31
    /**
32
     * PhoneNumberInterface constructor.
33
     *
34
     * @param int    $numberWithoutIDDCode
35
     * @param string $IDDCode
36
     */
37
    public function __construct($numberWithoutIDDCode, $IDDCode = null)
38
    {
39
        $this->number = $numberWithoutIDDCode;
40
        $this->IDDCode = $IDDCode ? intval(ltrim($IDDCode, '+0')) : null;
41
    }
42
43
    /**
44
     * 86.
45
     *
46
     * @return int
47
     */
48
    public function getIDDCode()
49
    {
50
        return $this->IDDCode;
51
    }
52
53
    /**
54
     * 18888888888.
55
     *
56
     * @return int
57
     */
58
    public function getNumber()
59
    {
60
        return $this->number;
61
    }
62
63
    /**
64
     * +8618888888888.
65
     *
66
     * @return string
67
     */
68
    public function getUniversalNumber()
69
    {
70
        return $this->getPrefixedIDDCode('+').$this->number;
71
    }
72
73
    /**
74
     * 008618888888888.
75
     *
76
     * @return string
77
     */
78
    public function getZeroPrefixedNumber()
79
    {
80
        return $this->getPrefixedIDDCode('00').$this->number;
81
    }
82
83
    /**
84
     * @param string $prefix
85
     *
86
     * @return null|string
87
     */
88
    public function getPrefixedIDDCode($prefix)
89
    {
90
        return $this->IDDCode ? $prefix.$this->IDDCode : null;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function __toString()
97
    {
98
        return $this->getUniversalNumber();
99
    }
100
101
    /**
102
     * Specify data which should be serialized to JSON.
103
     *
104
     * @see  http://php.net/manual/en/jsonserializable.jsonserialize.php
105
     *
106
     * @return mixed data which can be serialized by <b>json_encode</b>,
107
     *               which is a value of any type other than a resource
108
     *
109
     * @since 5.4.0
110
     */
111
    public function jsonSerialize()
112
    {
113
        return $this->getUniversalNumber();
114
    }
115
}
116