Completed
Pull Request — master (#95)
by
unknown
05:12
created

Statement::getSignedStartBalance()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 6
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) $s = -1;
77
		return $s * $this->getStartBalance();
78
79
	}
80
81
	/**
82
	 * Set startBalance
83
	 *
84
	 * @param float $startBalance
85
	 *
86
	 * @return $this
87
	 */
88 1
	public function setStartBalance($startBalance)
89
	{
90 1
		$this->startBalance = (float) $startBalance;
91
92 1
		return $this;
93
	}
94
95
	/**
96
	 * Get creditDebit
97
	 *
98
	 * @return string
99
	 */
100 1
	public function getCreditDebit()
101
	{
102 1
		return $this->creditDebit;
103
	}
104
105
	/**
106
	 * Set creditDebit
107
	 *
108
	 * @param string|null $creditDebit
109
	 *
110
	 * @return $this
111
	 */
112 1
	public function setCreditDebit($creditDebit)
113
	{
114 1
		$this->creditDebit = $creditDebit;
115
116 1
		return $this;
117
	}
118
119
	/**
120
	 * Get date
121
	 *
122
	 * @return \DateTime
123
	 */
124 1
	public function getDate()
125
	{
126 1
		return $this->date;
127
	}
128
129
	/**
130
	 * Set date
131
	 *
132
	 * @param \DateTime $date
133
	 *
134
	 * @return $this
135
	 */
136 1
	public function setDate(\DateTime $date)
137
	{
138 1
		$this->date = $date;
139
140 1
		return $this;
141
	}
142
}
143
144