Completed
Pull Request — master (#95)
by
unknown
02:37
created

Statement   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 79.31%

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 0
dl 0
loc 135
ccs 23
cts 29
cp 0.7931
rs 10
c 0
b 0
f 0

10 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 getSignedStartBalance() 0 8 2
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
	public function getSignedStartBalance()
74
	{
75
		$s = 1;
76
		if ($this->getCreditDebit() == self::CD_DEBIT) {
77
			$s = -1;
78
		}
79
		return $s * $this->getStartBalance();
80
	}
81
82
	/**
83
	 * Set startBalance
84
	 *
85
	 * @param float $startBalance
86
	 *
87
	 * @return $this
88
	 */
89 1
	public function setStartBalance($startBalance)
90
	{
91 1
		$this->startBalance = (float) $startBalance;
92
93 1
		return $this;
94
	}
95
96
	/**
97
	 * Get creditDebit
98
	 *
99
	 * @return string
100
	 */
101 1
	public function getCreditDebit()
102
	{
103 1
		return $this->creditDebit;
104
	}
105
106
	/**
107
	 * Set creditDebit
108
	 *
109
	 * @param string|null $creditDebit
110
	 *
111
	 * @return $this
112
	 */
113 1
	public function setCreditDebit($creditDebit)
114
	{
115 1
		$this->creditDebit = $creditDebit;
116
117 1
		return $this;
118
	}
119
120
	/**
121
	 * Get date
122
	 *
123
	 * @return \DateTime
124
	 */
125 1
	public function getDate()
126
	{
127 1
		return $this->date;
128
	}
129
130
	/**
131
	 * Set date
132
	 *
133
	 * @param \DateTime $date
134
	 *
135
	 * @return $this
136
	 */
137 1
	public function setDate(\DateTime $date)
138
	{
139 1
		$this->date = $date;
140
141 1
		return $this;
142
	}
143
}
144