ListenerSpy   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 5 1
A numberOfTimeCalled() 0 4 1
A wasCalledWith() 0 4 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