SubtractionOperation   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 2
b 0
f 0
dl 0
loc 16
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 7 2
1
<?php
2
3
namespace Tleckie\DesignPatterns\ChainResponsibility;
4
5
/**
6
 * Class SubtractionOperation
7
 *
8
 * @package Tleckie\DesignPatterns\ChainOfResponsibility
9
 * @author  Teodoro Leckie Westberg <[email protected]>
10
 */
11
class SubtractionOperation extends Handler
12
{
13
    /** @var string */
14
    protected const TYPE = 'SUBTRACTION';
15
16
    /**
17
     * @param OperationInterface $operation
18
     * @return float|null
19
     */
20
    public function handle(OperationInterface $operation): float|null
21
    {
22
        if ($operation->type() === static::TYPE) {
23
            return $operation->numberOne() - $operation->numberTwo();
24
        }
25
26
        return parent::handle($operation);
27
    }
28
}
29