Passed
Push — master ( 5f6dc3...b05beb )
by Andrea
19:20 queued 11s
created

FiController::getBundle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Controller;
4
5
use Cdf\BiCoreBundle\Service\Permessi\PermessiManager;
6
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
7
use Twig\Environment;
8
use Doctrine\ORM\EntityManagerInterface;
9
use function count;
10
use ReflectionClass;
11
12
class FiController extends AbstractController
13
{
14
    use FiCoreControllerTrait;
15
    use FiCoreCrudControllerTrait;
0 ignored issues
show
Bug introduced by
The trait Cdf\BiCoreBundle\Control...CoreCrudControllerTrait requires the property $request which is not provided by Cdf\BiCoreBundle\Controller\FiController.
Loading history...
16
    use FiCoreTabellaControllerTrait;
17
18
    protected string $bundle;
19
    protected Environment $template;
20
    protected string $controller;
21
    protected PermessiManager $permessi;
22
    protected EntityManagerInterface $em;
23
24 17
    public function __construct(PermessiManager $permessi, Environment $template, EntityManagerInterface $em)
25
    {
26 17
        $matches = [];
27 17
        $controllo = new ReflectionClass(get_class($this));
28
29 17
        preg_match('/(.*)\\\(.*)\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
30 17
        if (0 == count($matches)) {
31 10
            preg_match('/(.*)(.*)\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
32
        }
33
34 17
        $this->bundle = ($matches[count($matches) - 2] ? $matches[count($matches) - 2] : $matches[count($matches) - 3]);
35 17
        $this->controller = $matches[count($matches) - 1];
36 17
        $this->permessi = $permessi;
37 17
        $this->template = $template;
38 17
        $this->em = $em;
39 17
    }
40
41 15
    protected function getBundle()
42
    {
43 15
        return $this->bundle;
44
    }
45
46 17
    protected function getController()
47
    {
48 17
        return $this->controller;
49
    }
50
51 16
    protected function getPermessi()
52
    {
53 16
        return $this->permessi;
54
    }
55
56
    protected function getTemplate()
57
    {
58
        return $this->template;
59
    }
60
}
61