CallableEventListenerSpec   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A it_is_initializable() 0 3 1
A it_call_callable_on_execute() 0 5 2
A let() 0 7 1
1
<?php
2
3
/**
4
 * This file is part of slick/event package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace spec\Slick\Event\Application;
11
12
use Slick\Event\Application\CallableEventListener;
13
use PhpSpec\ObjectBehavior;
14
use Slick\Event\Event;
15
16
/**
17
 * CallableEventListenerSpec specs
18
 *
19
 * @package spec\Slick\Event\Application
20
 */
21
class CallableEventListenerSpec extends ObjectBehavior
22
{
23
    private bool $called = false;
24
    public function let()
25
    {
26
        $callable = function (object $event) {
27
            $this->called = true;
28
            return $event;
29
        };
30
        $this->beConstructedWith($callable);
31
    }
32
33
    function it_is_initializable()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
34
    {
35
        $this->shouldHaveType(CallableEventListener::class);
36
    }
37
38
    function it_call_callable_on_execute(Event $event)
39
    {
40
        $this->handle($event)->shouldBe($event);
0 ignored issues
show
Bug introduced by
The method handle() does not exist on spec\Slick\Event\Applica...llableEventListenerSpec. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
        $this->/** @scrutinizer ignore-call */ 
41
               handle($event)->shouldBe($event);
Loading history...
41
        if (!$this->called) {
42
            throw new \Exception("Callable listener not called");
43
        }
44
    }
45
}
46