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

Text   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 15.79 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 12
loc 76
ccs 20
cts 22
cp 0.9091
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getTitle() 0 4 1
A getPayload() 0 4 1
A getImageUrl() 0 4 1
A jsonSerialize() 12 12 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\QuickReply;
4
5
use Tgallice\FBMessenger\Model\QuickReply;
6
7
class Text extends QuickReply
8
{
9
    /**
10
     * @var string
11
     */
12
    private $title;
13
14
    /**
15
     * Payload
16
     *
17
     * @var string
18
     */
19
    private $payload;
20
    
21
    /**
22
     * @var string
23
     */
24
    private $image_url;
25
    
26
    /**
27
     * @param string $title
28
     * @param string $payload
29
     */
30 9
    public function __construct($title, $payload, $image_url = null)
31
    {
32 9
        parent::__construct(QuickReply::TYPE_TEXT);
33
    
34 9
        self::validateTitleSize($title);
35 8
        $this->title = $title;
36
    
37 8
        QuickReply::validatePayload($payload);
38 7
        $this->payload = $payload;
39
        
40 7
        $this->image_url = $image_url;
41 7
    }
42
    
43
    /**
44
     * @return string
45
     */
46 1
    public function getTitle()
47
    {
48 1
        return $this->title;
49
    }
50
    
51
    /**
52
     * @return string
53
     */
54 1
    public function getPayload()
55
    {
56 1
        return $this->payload;
57
    }
58
    
59
    /**
60
     * @return string
61
     */
62
    public function getImageUrl()
63
    {
64
        return $this->image_url;
65
    }
66
    
67
    /**
68
     * @inheritdoc
69
     */
70 2 View Code Duplication
    public function jsonSerialize()
1 ignored issue
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72 2
        $json = parent::jsonSerialize();
73 2
        $json['title'] = $this->title;
74 2
        $json['payload'] = $this->payload;
75
    
76 2
        if(!empty($this->image_url)) {
77 1
            $json['image_url'] = $this->image_url;
78 1
        }
79
        
80 2
        return $json;
81
    }
82
}
83