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.

Element::getDefaultAction()   A
last analyzed

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
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Tgallice\FBMessenger\Model\Attachment\Template\Generic;
4
5
use Tgallice\FBMessenger\Model\Button;
6
use Tgallice\FBMessenger\Model\Attachment\Template\AbstractElement;
7
use Tgallice\FBMessenger\Model\DefaultAction;
8
9
class Element extends AbstractElement
10
{
11
    /**
12
     * @var null|DefaultAction
13
     */
14
    private $defaultAction;
15
16
    /**
17
     * @var null|Button[]
18
     */
19
    private $buttons;
20
21
    /**
22
     * @param string $title
23
     */
24 9
    public function __construct($title, $subtitle = null, $imageUrl = null, array $buttons = null, DefaultAction $defaultAction = null)
25
    {
26 9
        parent::__construct($title, $subtitle, $imageUrl);
27
28 7
        if (count($buttons) > 3) {
29 1
            throw new \InvalidArgumentException('A generic element can not have more than 3 buttons.');
30
        }
31
32 6
        $this->buttons = $buttons;
33 6
        $this->defaultAction = $defaultAction;
34 6
    }
35
36
    /**
37
     * @return null|Button[]
38
     */
39 1
    public function getButtons()
40
    {
41 1
        return $this->buttons;
42
    }
43
44
    /**
45
     * @return null|DefaultAction
46
     */
47 1
    public function getDefaultAction()
48
    {
49 1
        return $this->defaultAction;
50
    }
51
52
    /**
53
     * @return array
54
     */
55 1 View Code Duplication
    public function jsonSerialize()
56
    {
57
        return [
58 1
            'title' => $this->getTitle(),
59 1
            'image_url' => $this->getImageUrl(),
60 1
            'subtitle' => $this->getSubtitle(),
61 1
            'buttons' => $this->buttons,
62 1
            'default_action' => $this->defaultAction,
63 1
        ];
64
    }
65
}
66