FixDiscountStrategy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 7 2
A __construct() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Cart\DiscountStrategy;
5
6
use Cart\Contracts\DiscountContract;
7
8
class FixDiscountStrategy implements DiscountContract
9
{
10
    /**
11
     * @var int
12
     */
13
    protected $sign;
14
15 3
    public function __construct(int $sign)
16
    {
17 3
        $this->sign = $sign;
18 3
    }
19
20
    /**
21
     * Make Discount
22
     *
23
     * @param int $basePrice
24
     * @return float
25
     */
26 2
    public function make(int $basePrice): float
27
    {
28 2
        $price = $basePrice - $this->sign;
29 2
        if ($price < 0) {
30 2
            $price =  0 ;
31
        }
32 2
        return $price;
33
    }
34
}