CartFee::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 7
rs 9.4285
cc 3
eloc 5
nc 4
nop 3
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