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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 20 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 10
loc 50
c 0
b 0
f 0
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getButton() 0 4 1
A getDefaultAction() 0 4 1
A jsonSerialize() 10 10 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Tgallice\FBMessenger\Model\Attachment\Template\ElementList;
4
5
use Tgallice\FBMessenger\Model\Attachment\Template\AbstractElement;
6
use Tgallice\FBMessenger\Model\Button;
7
use Tgallice\FBMessenger\Model\DefaultAction;
8
9
class Element extends AbstractElement
10
{
11
    /**
12
     * @var null|Button
13
     */
14
    private $button;
15
16
    /**
17
     * @var null|DefaultAction
18
     */
19
    private $defaultAction;
20
21
    /**
22
     * @param string $title
23
     * @param null|string $subtitle
24
     * @param null|string $imageUrl
25
     * @param Button|null $button
26
     * @param DefaultAction|null $defaultAction
27
     */
28 8
    public function __construct($title, $subtitle = null, $imageUrl = null, Button $button = null, DefaultAction $defaultAction = null)
29
    {
30 8
        parent::__construct($title, $subtitle, $imageUrl);
31 6
        $this->button = $button;
32 6
        $this->defaultAction = $defaultAction;
33 6
    }
34
35 1
    public function getButton()
36
    {
37 1
        return $this->button;
38
    }
39
40 1
    public function getDefaultAction()
41
    {
42 1
        return $this->defaultAction;
43
    }
44
45
    /**
46
     * @return array
47
     */
48 1 View Code Duplication
    public function jsonSerialize()
49
    {
50
        return [
51 1
            'title' => $this->getTitle(),
52 1
            'subtitle' => $this->getSubtitle(),
53 1
            'image_url' => $this->getImageUrl(),
54 1
            'buttons' => $this->button ? [$this->button] : null,
55 1
            'default_action' => $this->defaultAction,
56 1
        ];
57
    }
58
}
59