CallableEventListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 4 2
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of Event
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
declare(strict_types=1);
11
12
namespace Slick\Event\Application;
13
14
use Closure;
15
use Slick\Event\EventListener;
16
17
/**
18
 * CallableEventListener
19
 *
20
 * @package Slick\Event\Application
21
 */
22
final class CallableEventListener implements EventListener
23
{
24
25
    public function __construct(
26
        private Closure $listener
27
    ) {
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function handle(object $event): object
34
    {
35
        $result = ($this->listener)($event);
36
        return is_object($result) ? $result : $event;
37
    }
38
}
39