FiController   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 89.47%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 47
ccs 17
cts 19
cp 0.8947
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplate() 0 3 1
A getBundle() 0 3 1
A getController() 0 3 1
A getPermessi() 0 3 1
A __construct() 0 15 3
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 Doctrine\ORM\EntityManagerInterface;
8
use Twig\Environment;
9
use ReflectionClass;
10
11
use function count;
12
13
class FiController extends AbstractController
14
{
15
    use FiCoreControllerTrait;
16
    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...
17
    use FiCoreTabellaControllerTrait;
18
19
    protected string $bundle;
20
    protected Environment $template;
21
    protected string $controller;
22
    protected PermessiManager $permessi;
23
    protected EntityManagerInterface $em;
24
25 17
    public function __construct(PermessiManager $permessi, Environment $template, EntityManagerInterface $em)
26
    {
27 17
        $matches = [];
28 17
        $controllo = new ReflectionClass(get_class($this));
29
30 17
        preg_match('/(.*)\\\(.*)\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
31 17
        if (0 == count($matches)) {
32 10
            preg_match('/(.*)(.*)\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
33
        }
34
35 17
        $this->bundle = ($matches[count($matches) - 2] ? $matches[count($matches) - 2] : $matches[count($matches) - 3]);
36 17
        $this->controller = $matches[count($matches) - 1];
37 17
        $this->permessi = $permessi;
38 17
        $this->template = $template;
39 17
        $this->em = $em;
40
    }
41
42 15
    protected function getBundle(): string
43
    {
44 15
        return $this->bundle;
45
    }
46
47 17
    protected function getController(): string
48
    {
49 17
        return $this->controller;
50
    }
51
52 16
    protected function getPermessi(): PermessiManager
53
    {
54 16
        return $this->permessi;
55
    }
56
57
    protected function getTemplate(): Environment
58
    {
59
        return $this->template;
60
    }
61
}
62