SubtractionCount::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
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
}