Executor::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: polidog
5
 * Date: 2017/05/13
6
 * Time: 0:52.
7
 */
8
9
namespace Polidog\ControllerFilterBundle;
10
11
use Polidog\ControllerFilterBundle\Annotations\FilterInterface;
12
use Polidog\ControllerFilterBundle\Exception\UnexpectedValueException;
13
use Symfony\Component\DependencyInjection\ContainerInterface;
14
use Symfony\Component\HttpKernel\Event\KernelEvent;
15
16
class Executor
17
{
18
    /**
19
     * @var ContainerInterface
20
     */
21
    private $container;
22
23
    /**
24
     * Executor constructor.
25
     *
26
     * @param ContainerInterface $container
27
     */
28
    public function __construct(ContainerInterface $container)
29
    {
30
        $this->container = $container;
31
    }
32
33
    /**
34
     * @param FilterInterface $filter
35
     * @param KernelEvent     $event
36
     *
37
     * @return mixed
38
     */
39
    public function run(FilterInterface $filter, KernelEvent $event)
40
    {
41
        if (false === $this->container->has($filter->getService())) {
42
            throw new UnexpectedValueException('Missing countainer id: '.$filter->getService());
43
        }
44
45
        return call_user_func_array([$this->container->get($filter->getService()), $filter->getMethod()], [$event]);
46
    }
47
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
48