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
Pull Request — master (#15)
by Gallice
03:19
created

Button::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Tgallice\FBMessenger\Model;
4
5
abstract class Button implements \JsonSerializable
6
{
7
    const TYPE_POSTBACK = 'postback';
8
    const TYPE_PHONE_NUMBER = 'phone_number';
9
    const TYPE_WEB_URL = 'web_url';
10
    const TYPE_SHARE = 'element_share';
11
12
    /**
13
     * @var string
14
     */
15
    private $type;
16
17
    /**
18
     * @param string $type
19
     */
20 35
    public function __construct($type)
21
    {
22 35
        $this->type = $type;
23 35
    }
24
25
    /**
26
     * @return string
27
     */
28 4
    public function getType()
29
    {
30 4
        return $this->type;
31
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 5
    public function jsonSerialize()
37
    {
38
        $json = [
39 5
            'type' => $this->type,
40 5
        ];
41
42 5
        return $json;
43
    }
44
45
    /**
46
     * @param string $title
47
     *
48
     * @throws \InvalidArgumentException
49
     */
50 31
    public static function validateTitleSize($title)
51
    {
52 31
        if (mb_strlen($title) > 20) {
53 3
            throw new \InvalidArgumentException('The button title field should not exceed 20 characters.');
54
        }
55 28
    }
56
57
    /**
58
     * @param $payload
59
     *
60
     * @throws \InvalidArgumentException
61
     */
62 7
    public static function validatePayload($payload)
63
    {
64 7
        if (mb_strlen($payload) > 1000) {
65 1
            throw new \InvalidArgumentException(sprintf(
66 1
                    'Payload should not exceed 1000 characters.', $payload)
67 1
            );
68
        }
69 6
    }
70
71
    /**
72
     * @param $phoneNumber
73
     *
74
     * @throws \InvalidArgumentException
75
     */
76 7
    public static function validatePhoneNumber($phoneNumber)
77
    {
78
        // Dummy phone number check
79 7
        if (strpos($phoneNumber, '+') !== 0) {
80 1
            throw new \InvalidArgumentException(sprintf(
81 1
                    'The phone number "%s" seem to be invalid. Please check the documentation to format the phone number.', $phoneNumber)
82 1
            );
83
        }
84 6
    }
85
}
86