SumOperation::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Tleckie\DesignPatterns\ChainResponsibility;
4
5
/**
6
 * Class SumOperation
7
 *
8
 * @package Tleckie\DesignPatterns\ChainOfResponsibility
9
 * @author  Teodoro Leckie Westberg <[email protected]>
10
 */
11
class SumOperation extends Handler
12
{
13
    /** @var string */
14
    protected const TYPE = 'SUM';
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