Passed
Push — develop ( 8a58bb...763b43 )
by Andrea
26:21 queued 11:17
created

FiController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 89.47%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 45
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 __construct() 0 14 3
A getTemplate() 0 3 1
A getBundle() 0 3 1
A getController() 0 3 1
A getPermessi() 0 3 1
1
<?php
2
3
namespace Cdf\BiCoreBundle\Controller;
4
5
use Cdf\BiCoreBundle\Service\Permessi\PermessiManager;
6
use function count;
7
use ReflectionClass;
8
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
9
use Twig\Environment;
10
11
class FiController extends AbstractController
12
{
13
    use FiCoreControllerTrait;
14
    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...
15
    use FiCoreTabellaControllerTrait;
16
17
    protected $bundle;
18
    protected $template;
19
    protected $controller;
20
    protected $permessi;
21
22 17
    public function __construct(PermessiManager $permessi, Environment $template)
23
    {
24 17
        $matches = [];
25 17
        $controllo = new ReflectionClass(get_class($this));
26
27 17
        preg_match('/(.*)\\\(.*)\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
28 17
        if (0 == count($matches)) {
29 10
            preg_match('/(.*)(.*)\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
30
        }
31
32 17
        $this->bundle = ($matches[count($matches) - 2] ? $matches[count($matches) - 2] : $matches[count($matches) - 3]);
33 17
        $this->controller = $matches[count($matches) - 1];
34 17
        $this->permessi = $permessi;
35 17
        $this->template = $template;
36 17
    }
37
38 12
    protected function getBundle()
39
    {
40 12
        return $this->bundle;
41
    }
42
43 17
    protected function getController()
44
    {
45 17
        return $this->controller;
46
    }
47
48 16
    protected function getPermessi()
49
    {
50 16
        return $this->permessi;
51
    }
52
53
    protected function getTemplate()
54
    {
55
        return $this->template;
56
    }
57
}
58