ObserverCallable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 26
rs 10
c 0
b 0
f 0
ccs 6
cts 6
cp 1
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A update() 0 3 1
A getCallable() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EngineWorks\ProgressStatus;
6
7
use SplObserver;
8
use SplSubject;
9
10
class ObserverCallable implements SplObserver
11
{
12
    /** @var callable(SplSubject):void */
13
    private $callable;
14
15
    /**
16
     * ObserverCallable constructor.
17
     *
18
     * @param callable(SplSubject):void $callable
19
     */
20 2
    public function __construct(callable $callable)
21
    {
22 2
        $this->callable = $callable;
23
    }
24
25 1
    public function update(SplSubject $subject): void
26
    {
27 1
        call_user_func($this->callable, $subject);
28
    }
29
30
    /**
31
     * @return callable(SplSubject):void
32
     */
33 1
    public function getCallable(): callable
34
    {
35 1
        return $this->callable;
36
    }
37
}
38