Completed
Push — develop ( 10c561...c9c07e )
by Remco
11:05
created

TaxedMoney::get_tax_amount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Taxed Money
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Money
9
 */
10
11
namespace Pronamic\WordPress\Money;
12
13
/**
14
 * Taxed Money
15
 *
16
 * @author Remco Tolsma
17
 * @version 1.0.0
18
 * @since   1.0.0
19
 */
20
class TaxedMoney extends Money {
21
	/**
22
	 * Tax amount.
23
	 *
24
	 * @var float|null
25
	 */
26
	private $tax_amount;
27
28
	/**
29
	 * Tax percentage.
30
	 *
31
	 * @var float|null
32
	 */
33
	private $tax_percentage;
34
35
	/**
36
	 * Construct and initialize money object.
37
	 *
38
	 * @param string|int|float     $amount   Amount.
39
	 * @param Currency|string|null $currency Currency.
40
	 */
41
	public function __construct( $amount = 0, $currency = null, $tax_amount = null, $tax_percentage = null ) {
42
		parent::__construct( $amount, $currency );
43
44
		$this->set_tax_amount( $tax_amount );
45
		$this->set_tax_percentage( $tax_percentage );
46
	}
47
48
	/**
49
	 * Get tax amount.
50
	 *
51
	 * @return float Tax amount.
52
	 */
53
	public function get_tax_amount() {
54
		return $this->tax_amount;
55
	}
56
57
	/**
58
	 * Set tax amount.
59
	 *
60
	 * @param mixed $amount Tax amount.
61
	 */
62
	public function set_tax_amount( $amount ) {
63
		$this->tax_amount = floatval( $amount );
64
	}
65
66
	/**
67
	 * Get tax percentage.
68
	 *
69
	 * @return float
70
	 */
71
	public function get_tax_percentage() {
72
		return $this->tax_percentage;
73
	}
74
75
	/**
76
	 * Set tax percentage.
77
	 *
78
	 * @param mixed $tax_percentage Tax percentage.
0 ignored issues
show
Documentation introduced by
There is no parameter named $tax_percentage. Did you maybe mean $percentage?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
79
	 */
80
	public function set_tax_percentage( $percentage ) {
81
		$this->tax_percentage = floatval( $percentage );
82
	}
83
84
	/**
85
	 * Get including tax.
86
	 *
87
	 * @return Money
88
	 */
89
	public function get_including_tax() {
90
		return new Money( $this->get_amount(), $this->get_currency() );
91
	}
92
93
	/**
94
	 * Get excluding tax.
95
	 *
96
	 * @return Money
97
	 */
98
	public function get_excluding_tax() {
99
		$value = $this->get_amount();
100
101
		if ( null !== $this->get_tax_amount() ) {
102
			$value -= $this->get_tax_amount();
103
		}
104
105
		return new Money( $value, $this->get_currency() );
106
	}
107
}
108