Invoice   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 142
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 11
eloc 23
c 3
b 0
f 0
dl 0
loc 142
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A uuid() 0 8 2
A amount() 0 8 2
A getUuid() 0 3 1
A getDriver() 0 3 1
A getTransactionId() 0 3 1
A via() 0 5 1
A getAmount() 0 3 1
A transactionId() 0 5 1
1
<?php
2
3
namespace Shetabit\Multipay;
4
5
use Ramsey\Uuid\Uuid;
6
use Shetabit\Multipay\Traits\HasDetail;
7
8
class Invoice
9
{
10
    use HasDetail;
11
12
    /**
13
     * invoice's unique universal id (uuid)
14
     *
15
     * @var string
16
     */
17
    protected $uuid;
18
19
    /**
20
     * Amount
21
     *
22
     * @var int|float
23
     */
24
    protected $amount = 0;
25
26
    /**
27
     * invoice's transaction id
28
     *
29
     * @var string
30
     */
31
    protected $transactionId;
32
33
    /**
34
     * @var string
35
     */
36
    protected $driver;
37
38
    /**
39
     * Invoice constructor.
40
     *
41
     * @throws \Exception
42
     */
43
    public function __construct()
44
    {
45
        $this->uuid();
46
    }
47
48
    /**
49
     * Set invoice uuid
50
     *
51
     * @param $uuid|null
52
     *
53
     * @throws \Exception
54
     */
55
    public function uuid($uuid = null)
56
    {
57
        if (empty($uuid)) {
58
            $uuid = Uuid::uuid4()->toString();
59
        }
60
61
        $this->uuid = $uuid;
62
        return $this;
63
    }
64
65
    /**
66
     * Get invoice uuid
67
     *
68
     * @return string
69
     */
70
    public function getUuid()
71
    {
72
        return $this->uuid;
73
    }
74
75
    /**
76
     * Set the amount of invoice
77
     *
78
     * @param $amount
79
     *
80
     * @return $this
81
     *
82
     * @throws \Exception
83
     */
84
    public function amount($amount)
85
    {
86
        if (!is_numeric($amount)) {
87
            throw new \Exception('Amount value should be a number (integer or float).');
88
        }
89
        $this->amount = $amount;
90
91
        return $this;
92
    }
93
94
    /**
95
     * Get the value of invoice
96
     *
97
     * @return int|float
98
     */
99
    public function getAmount()
100
    {
101
        return $this->amount;
102
    }
103
104
    /**
105
     * set transaction id
106
     *
107
     * @param $id
108
     *
109
     * @return $this
110
     */
111
    public function transactionId($id)
112
    {
113
        $this->transactionId = $id;
114
115
        return $this;
116
    }
117
118
    /**
119
     * Get the value of transaction's id
120
     *
121
     * @return string
122
     */
123
    public function getTransactionId()
124
    {
125
        return $this->transactionId;
126
    }
127
128
    /**
129
     * Set the value of driver
130
     *
131
     * @param $driver
132
     *
133
     * @return $this
134
     */
135
    public function via($driver)
136
    {
137
        $this->driver = $driver;
138
139
        return $this;
140
    }
141
142
    /**
143
     * Get the value of driver
144
     *
145
     * @return string
146
     */
147
    public function getDriver()
148
    {
149
        return $this->driver;
150
    }
151
}
152