Test Failed
Push — master ( 622303...1df567 )
by Jean-Bernard
03:29 queued 01:30
created

Identity   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 9
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the Symfony-Util package.
5
 *
6
 * (c) Jean-Bernard Addor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tests\FrameworkTwig;
13
14
use Knp\Rad\ResourceResolver\Bundle\ResourceResolverBundle;
15
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
16
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
17
use Symfony\Bundle\TwigBundle\TwigBundle;
18
use Symfony\Bundle\WebServerBundle\WebServerBundle;
19
use Symfony\Component\Config\Loader\LoaderInterface;
20
use Symfony\Component\DependencyInjection\ContainerBuilder;
21
use Symfony\Component\HttpKernel\Kernel;
22
use Symfony\Component\Routing\Route;
23
use Symfony\Component\Routing\RouteCollectionBuilder;
24
use SymfonyUtil\Controller\EngineAsArgumentController;
25
use SymfonyUtil\Controller\TemplatingController;
26
use SymfonyUtil\Controller\VariadicController;
27
28
class Identity
29
{
30
    public function __invoke($a)
31
    {
32
        dump($a);
33
34
        return $a;
35
    }
36
}
37
38
class AppKernel extends Kernel
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
39
{
40
    use MicroKernelTrait;
41
42
    public function registerBundles()
43
    {
44
        return [
45
            new FrameworkBundle(),
46
            new ResourceResolverBundle(),
47
            new TwigBundle(),
48
            new WebServerBundle()
49
        ];
50
    }
51
52
    protected function configureRoutes(RouteCollectionBuilder $routes)
53
    {
54
        $routes->add('/', EngineAsArgumentController::class, 'index');
55
        $routes->add('/argument', EngineAsArgumentController::class, 'argument');
56
        $routes->add('/constructor', TemplatingController::class, 'constructor');
57
        $routes->addRoute(new Route('/variadic/request', [
58
                '_controller' => VariadicController::class,
59
                '_resources' => ['\Identity', ['request']],
60
            ]),
61
            'variadic_request'
62
        );
63
    }
64
65
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
0 ignored issues
show
Unused Code introduced by
The parameter $loader is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        //Controllers
68
        $c->autowire(EngineAsArgumentController::class)
69
            ->setAutoconfigured(true)
70
            ->addTag('controller.service_arguments')
71
            ->setPublic(true);
72
73
        $c->autowire(TemplatingController::class)
74
            ->setAutoconfigured(true)
75
            // ->addTag('controller.service_arguments')
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
76
            ->setPublic(true);
77
78
        $c->autowire(VariadicController::class)
79
            ->setAutoconfigured(true)
80
            ->setPublic(true);
81
82
        $c->autowire('\Identity')
83
            ->setAutoconfigured(true)
84
            ->setPublic(true);
85
86
        // Extensions
87
        $c->loadFromExtension('framework', [
88
            'secret' => 'NotSecret', // What about use $ uuid -v4  or $ uuidgen
89
            'test' => in_array($this->getEnvironment(), ['test'], true), // test.client service for eg. PHPUnit
90
            'templating' => ['engines' => 'twig'],
91
        ]);
92
        $c->loadFromExtension('twig', [
93
            'debug' => true,
94
            'paths' => ['%kernel.project_dir%/tests/templates'],
95
        ]);
96
    }
97
}
98