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.
Completed
Push — master ( 684db7...9d7eb5 )
by
unknown
02:03
created

Project   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 112
Duplicated Lines 13.39 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 2
dl 15
loc 112
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 15 15 5
A validate() 0 11 3
A toArray() 0 9 1
A getId() 0 4 1
A getName() 0 4 1
A getPage() 0 4 1
A getDomain() 0 4 1

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 LPTracker\models;
4
5
use LPTracker\exceptions\LPTrackerSDKException;
6
7
/**
8
 * Class Project
9
 * @package LPTracker\models
10
 */
11
class Project extends Model
12
{
13
14
    /**
15
     * @var integer
16
     */
17
    protected $id;
18
19
    /**
20
     * @var string
21
     */
22
    protected $name;
23
24
    /**
25
     * @var string
26
     */
27
    protected $page;
28
29
    /**
30
     * @var string
31
     */
32
    protected $domain;
33
34
35
    /**
36
     * Project constructor.
37
     *
38
     * @param array $options
39
     */
40 View Code Duplication
    public function __construct(array $options = [])
0 ignored issues
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...
41
    {
42
        if (isset($options['id'])) {
43
            $this->id = $options['id'];
44
        }
45
        if (isset($options['name'])) {
46
            $this->name = $options['name'];
47
        }
48
        if (isset($options['page'])) {
49
            $this->page = $options['page'];
50
        }
51
        if (isset($options['domain'])) {
52
            $this->page = $options['domain'];
53
        }
54
    }
55
56
57
    /**
58
     * @return bool
59
     * @throws LPTrackerSDKException
60
     */
61
    public function validate()
62
    {
63
        if (empty($this->id)) {
64
            throw new LPTrackerSDKException('Project ID is required');
65
        }
66
        if (empty($this->name)) {
67
            throw new LPTrackerSDKException('Project name is required');
68
        }
69
70
        return true;
71
    }
72
73
74
    /**
75
     * @return array
76
     */
77
    public function toArray()
78
    {
79
        return [
80
            'id'     => $this->getId(),
81
            'name'   => $this->getName(),
82
            'page'   => $this->getPage(),
83
            'domain' => $this->getDomain()
84
        ];
85
    }
86
87
88
    /**
89
     * @return int
90
     */
91
    public function getId()
92
    {
93
        return intval($this->id);
94
    }
95
96
97
    /**
98
     * @return string
99
     */
100
    public function getName()
101
    {
102
        return $this->name;
103
    }
104
105
106
    /**
107
     * @return string
108
     */
109
    public function getPage()
110
    {
111
        return $this->page;
112
    }
113
114
115
    /**
116
     * @return string
117
     */
118
    public function getDomain()
119
    {
120
        return $this->domain;
121
    }
122
}