CartFee::getAmount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace LukePOLO\LaraCart;
4
5
use LukePOLO\LaraCart\Traits\CartOptionsMagicMethodsTrait;
6
7
/**
8
 * Class CartFee.
9
 */
10
class CartFee
11
{
12
    use CartOptionsMagicMethodsTrait;
13
14
    public $locale;
15
    public $amount;
16
    public $taxable;
17
    public $tax;
18
    public $internationalFormat;
19
20
    /**
21
     * CartFee constructor.
22
     *
23
     * @param $amount
24
     * @param $taxable
25
     * @param array $options
26
     */
27
    public function __construct($amount, $taxable = false, $options = [])
28
    {
29
        $this->amount = floatval($amount);
30
        $this->taxable = $taxable;
31
        $this->tax = isset($options['tax']) ? $options['tax'] == 0 ? config('laracart.tax') : $options['tax'] : config('laracart.tax');
32
        $this->options = $options;
33
    }
34
35
    /**
36
     * Gets the formatted amount.
37
     *
38
     * @return string
39
     */
40
    public function getAmount()
41
    {
42
        return LaraCart::formatMoney($this->amount, $this->locale, $this->internationalFormat);
43
    }
44
}
45