SubtractionCount   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 5 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Cart\CountOperation;
5
6
use Cart\Contracts\CounterItemContract;
7
8
/**
9
 * Class SubtractionCount
10
 *
11
 * @package CountOperation
12
 */
13
class SubtractionCount implements CounterItemContract
14
{
15
    /**
16
     * Operation
17
     *
18
     * @param int $before
19
     * @param int $howMuch
20
     * @return int
21
     */
22 1
    public function execute(int $before, int $howMuch): int
23
    {
24 1
        $value = $before - $howMuch;
25 1
        $value < 0 ? $value = 0 : true;
26 1
        return $value;
27
    }
28
}