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 ( 6cf912...554d1b )
by Gallice
03:11
created

QuickReply   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 60
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getContentType() 0 4 1
A jsonSerialize() 0 6 1
A validateTitleSize() 0 6 2
A validatePayload() 0 6 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 $contentType;
14
15
    /**
16
     * @param string $contentType TYPE_*
17
     */
18 13
    public function __construct($contentType)
19
    {
20 13
        $this->contentType = $contentType;
21 13
    }
22
23
    /**
24
     * @return string
25
     */
26 2
    public function getContentType()
27
    {
28 2
        return $this->contentType;
29
    }
30
    
31
    /**
32
     * @inheritdoc
33
     */
34 3
    public function jsonSerialize()
35
    {
36
        return [
37 3
            'content_type' => $this->contentType,
38 3
        ];
39
    }
40
    
41
    /**
42
     * @param string $title
43
     *
44
     * @throws \InvalidArgumentException
45
     */
46 9
    public static function validateTitleSize($title)
47
    {
48 9
        if (mb_strlen($title) > 20) {
49 1
            throw new \InvalidArgumentException('The button title field should not exceed 20 characters.');
50
        }
51 8
    }
52
    
53
    /**
54
     * @param $payload
55
     *
56
     * @throws \InvalidArgumentException
57
     */
58 8
    public static function validatePayload($payload)
59
    {
60 8
        if (mb_strlen($payload) > 1000) {
61 1
            throw new \InvalidArgumentException(sprintf('Payload should not exceed 1000 characters.', $payload));
62
        }
63 7
    }
64
}
65