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

FiController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
eloc 22
dl 0
loc 47
ccs 18
cts 20
cp 0.9
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 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