ObserverCallable::getCallable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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