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

Payment   A

Complexity

Total Complexity 18

Size/Duplication

Total Lines 142
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 18
lcom 1
cbo 2
dl 0
loc 142
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 4
A toArray() 0 14 4
A validate() 0 14 4
A getCategory() 0 4 1
A setCategory() 0 6 1
A getPurpose() 0 4 1
A setPurpose() 0 6 1
A getSum() 0 4 1
A setSum() 0 6 1
1
<?php
2
3
namespace LPTracker\models;
4
5
use LPTracker\exceptions\LPTrackerSDKException;
6
7
/**
8
 * Class Payment
9
 * @package LPTracker\models
10
 */
11
class Payment extends Model
12
{
13
14
    /**
15
     * @var string
16
     */
17
    protected $category;
18
19
    /**
20
     * @var string
21
     */
22
    protected $purpose;
23
24
    /**
25
     * @var float
26
     */
27
    protected $sum;
28
29
30
    /**
31
     * Payment constructor.
32
     *
33
     * @param array $paymentData
34
     */
35
    public function __construct(array $paymentData = [])
36
    {
37
        if ( ! empty($paymentData['category'])) {
38
            $this->category = $paymentData['category'];
39
        }
40
        if ( ! empty($paymentData['purpose'])) {
41
            $this->purpose = $paymentData['purpose'];
42
        }
43
        if ( ! empty($paymentData['sum'])) {
44
            $this->sum = $paymentData['sum'];
45
        }
46
    }
47
48
49
    /**
50
     *
51
     */
52
    public function toArray()
53
    {
54
        $result = [];
55
56
        if ( ! empty($this->category)) {
57
            $result['category'] = $this->getCategory();
58
        }
59
        if ( ! empty($this->purpose)) {
60
            $result['purpose'] = $this->getPurpose();
61
        }
62
        if ( ! empty($this->sum)) {
63
            $result['sum'] = $this->getSum();
64
        }
65
    }
66
67
68
    /**
69
     * @return bool
70
     * @throws LPTrackerSDKException
71
     */
72
    public function validate()
73
    {
74
        if (empty($this->category)) {
75
            throw new LPTrackerSDKException('Payment category is required');
76
        }
77
        if (empty($this->purpose)) {
78
            throw new LPTrackerSDKException('Payment purpose is required');
79
        }
80
        if ( ! isset($this->sum)) {
81
            throw new LPTrackerSDKException('Payment sum is required');
82
        }
83
84
        return true;
85
    }
86
87
88
    /**
89
     * @return string
90
     */
91
    public function getCategory()
92
    {
93
        return $this->category;
94
    }
95
96
97
    /**
98
     * @param string $category
99
     *
100
     * @return $this
101
     */
102
    public function setCategory($category)
103
    {
104
        $this->category = $category;
105
106
        return $this;
107
    }
108
109
110
    /**
111
     * @return string
112
     */
113
    public function getPurpose()
114
    {
115
        return $this->purpose;
116
    }
117
118
119
    /**
120
     * @param string $purpose
121
     *
122
     * @return $this
123
     */
124
    public function setPurpose($purpose)
125
    {
126
        $this->purpose = $purpose;
127
128
        return $this;
129
    }
130
131
132
    /**
133
     * @return float
134
     */
135
    public function getSum()
136
    {
137
        return $this->sum;
138
    }
139
140
141
    /**
142
     * @param float $sum
143
     *
144
     * @return $this
145
     */
146
    public function setSum($sum)
147
    {
148
        $this->sum = $sum;
149
150
        return $this;
151
    }
152
}