AbstractWellCommerceBundle   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 10

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 10
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 12 1
A registerBundles() 0 14 2
1
<?php
2
/*
3
 * WellCommerce Open-Source E-Commerce Platform
4
 * 
5
 * This file is part of the WellCommerce package.
6
 *
7
 * (c) Adam Piotrowski <[email protected]>
8
 * 
9
 * For the full copyright and license information,
10
 * please view the LICENSE file that was distributed with this source code.
11
 */
12
13
namespace WellCommerce\Bundle\CoreBundle\HttpKernel;
14
15
use Doctrine\Common\Collections\Collection;
16
use Symfony\Component\DependencyInjection\ContainerBuilder;
17
use Symfony\Component\HttpKernel\Bundle\Bundle;
18
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterControllerPass;
19
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterDataGridPass;
20
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterDataSetPass;
21
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterEntityFactoryPass;
22
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterFormBuilderPass;
23
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterManagerPass;
24
use WellCommerce\Bundle\CoreBundle\DependencyInjection\Compiler\AutoRegisterRepositoryPass;
25
26
/**
27
 * Class AbstractWellCommerceBundle
28
 *
29
 * @author  Adam Piotrowski <[email protected]>
30
 */
31
abstract class AbstractWellCommerceBundle extends Bundle
32
{
33
    public function build(ContainerBuilder $container)
34
    {
35
        parent::build($container);
36
        
37
        $container->addCompilerPass(new AutoRegisterRepositoryPass($this));
38
        $container->addCompilerPass(new AutoRegisterEntityFactoryPass($this));
39
        $container->addCompilerPass(new AutoRegisterDataSetPass($this));
40
        $container->addCompilerPass(new AutoRegisterDataGridPass($this));
41
        $container->addCompilerPass(new AutoRegisterFormBuilderPass($this));
42
        $container->addCompilerPass(new AutoRegisterManagerPass($this));
43
        $container->addCompilerPass(new AutoRegisterControllerPass($this));
44
    }
45
    
46
    public static function registerBundles(Collection $bundles, string $environment)
47
    {
48
        /**
49
         *  http://php.net/manual/en/language.oop5.late-static-bindings.php
50
         *  Now not need override this method in child class by default
51
         *  late static binding returned called instanse an not this(self)
52
         */
53
54
        $bundles->add(new static());
55
56
        if($environment === 'dev'){
0 ignored issues
show
Unused Code introduced by diversantvlz
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
57
            // add bundles for dev
58
        }
59
    }
60
}
61