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.
Passed
Push — master ( 7de461...6cf912 )
by Gallice
04:54
created

QuickReply::validateTitleSize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Tgallice\FBMessenger\Model;
4
5
abstract class QuickReply implements \JsonSerializable
6
{
7
    const TYPE_TEXT = 'text';
8
    const TYPE_LOCATION = 'location';
9
    
10
    /**
11
     * @var string
12
     */
13
    private $type;
14
15
    /**
16
     * @param string $type
17
     */
18 13
    public function __construct($type)
19
    {
20 13
        $this->type = $type;
21 13
    }
22
23
    /**
24
     * @return string
25
     */
26 2
    public function getType()
27
    {
28 2
        return $this->type;
29
    }
30
    
31
    /**
32
     * @inheritdoc
33
     */
34 3
    public function jsonSerialize()
35
    {
36
        $json = [
37 3
            'type' => $this->type,
38 3
        ];
39
40 3
        return $json;
41
    }
42
    
43
    /**
44
     * @param string $title
45
     *
46
     * @throws \InvalidArgumentException
47
     */
48 9
    public static function validateTitleSize($title)
49
    {
50 9
        if (mb_strlen($title) > 20) {
51 1
            throw new \InvalidArgumentException('The button title field should not exceed 20 characters.');
52
        }
53 8
    }
54
    
55
    /**
56
     * @param $payload
57
     *
58
     * @throws \InvalidArgumentException
59
     */
60 8
    public static function validatePayload($payload)
61
    {
62 8
        if (mb_strlen($payload) > 1000) {
63 1
            throw new \InvalidArgumentException(sprintf('Payload should not exceed 1000 characters.', $payload));
64
        }
65 7
    }
66
}
67