ListenerSpy::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace League\Event;
6
7
class ListenerSpy implements Listener
8
{
9
    /**
10
     * @var object|null
11
     */
12
    private $calledWith = null;
13
14
    /**
15
     * @var int
16
     */
17
    private $timesCalled = 0;
18
19
    public function __invoke(object $event): void
20
    {
21
        $this->timesCalled += 1;
22
        $this->calledWith = $event;
23
    }
24
25
    public function numberOfTimeCalled(): int
26
    {
27
        return $this->timesCalled;
28
    }
29
30
    public function wasCalledWith(object $event): bool
31
    {
32
        return $event === $this->calledWith;
33
    }
34
}
35