Statement   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 126
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 126
c 0
b 0
f 0
wmc 9
lcom 1
cbo 0
ccs 23
cts 23
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getTransactions() 0 4 1
A setTransactions() 0 6 1
A addTransaction() 0 4 1
A getStartBalance() 0 4 1
A setStartBalance() 0 6 1
A getCreditDebit() 0 4 1
A setCreditDebit() 0 6 1
A getDate() 0 4 1
A setDate() 0 6 1
1
<?php
2
3
namespace Fhp\Model\StatementOfAccount;
4
5
/**
6
 * Class Statement
7
 * @package Fhp\Model\StatementOfAccount
8
 */
9
class Statement
10
{
11
    const CD_CREDIT = 'credit';
12
    const CD_DEBIT = 'debit';
13
14
    /**
15
     * @var array of Transaction
16
     */
17
    protected $transactions = array();
18
19
    /**
20
     * @var float
21
     */
22
    protected $startBalance = 0.0;
23
24
    /**
25
     * @var string
26
     */
27
    protected $creditDebit;
28
29
    /**
30
     * @var \DateTime|null
31
     */
32
    protected $date;
33
34
    /**
35
     * Get transactions
36
     *
37
     * @return Transaction[]
38
     */
39 1
    public function getTransactions()
40
    {
41 1
        return $this->transactions;
42
    }
43
44
    /**
45
     * Set transactions
46
     *
47
     * @param array $transactions
48
     *
49
     * @return $this
50
     */
51 1
    public function setTransactions(array $transactions = null)
52
    {
53 1
        $this->transactions = $transactions;
0 ignored issues
show
Documentation Bug introduced by
It seems like $transactions can be null. However, the property $transactions is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
54
55 1
        return $this;
56
    }
57
58 1
    public function addTransaction(Transaction $transaction)
59
    {
60 1
        $this->transactions[] = $transaction;
61 1
    }
62
63
    /**
64
     * Get startBalance
65
     *
66
     * @return float
67
     */
68 1
    public function getStartBalance()
69
    {
70 1
        return $this->startBalance;
71
    }
72
73
    /**
74
     * Set startBalance
75
     *
76
     * @param float $startBalance
77
     *
78
     * @return $this
79
     */
80 1
    public function setStartBalance($startBalance)
81
    {
82 1
        $this->startBalance = (float) $startBalance;
83
84 1
        return $this;
85
    }
86
87
    /**
88
     * Get creditDebit
89
     *
90
     * @return string
91
     */
92 1
    public function getCreditDebit()
93
    {
94 1
        return $this->creditDebit;
95
    }
96
97
    /**
98
     * Set creditDebit
99
     *
100
     * @param string|null $creditDebit
101
     *
102
     * @return $this
103
     */
104 1
    public function setCreditDebit($creditDebit)
105
    {
106 1
        $this->creditDebit = $creditDebit;
107
108 1
        return $this;
109
    }
110
111
    /**
112
     * Get date
113
     *
114
     * @return \DateTime
115
     */
116 1
    public function getDate()
117
    {
118 1
        return $this->date;
119
    }
120
121
    /**
122
     * Set date
123
     *
124
     * @param \DateTime $date
125
     *
126
     * @return $this
127
     */
128 1
    public function setDate(\DateTime $date)
129
    {
130 1
        $this->date = $date;
131
132 1
        return $this;
133
    }
134
}
135