Passed
Push — master ( d946b3...61034d )
by Jacques
13:52 queued 02:30
created

MonsieurBizSyliusSalesReportsPlugin   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 11
c 0
b 0
f 0
dl 0
loc 26
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getContainerExtension() 0 15 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace MonsieurBiz\SyliusSalesReportsPlugin;
6
7
use Sylius\Bundle\CoreBundle\Application\SyliusPluginTrait;
8
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
9
use Symfony\Component\HttpKernel\Bundle\Bundle;
10
11
final class MonsieurBizSyliusSalesReportsPlugin extends Bundle
12
{
13
    use SyliusPluginTrait;
14
15
    /**
16
     * Returns the plugin's container extension.
17
     *
18
     * @return ExtensionInterface|null The container extension
19
     *
20
     * @throws \LogicException
21
     */
22
    public function getContainerExtension(): ?ExtensionInterface
23
    {
24
        if (null === $this->containerExtension) {
25
            $extension = $this->createContainerExtension();
26
27
            if (null !== $extension) {
28
                if (!$extension instanceof ExtensionInterface) {
0 ignored issues
show
introduced by
$extension is always a sub-type of Symfony\Component\Depend...sion\ExtensionInterface.
Loading history...
29
                    throw new \LogicException(sprintf('Extension %s must implement %s.', get_class($extension), ExtensionInterface::class));
30
                }
31
                $this->containerExtension = $extension;
32
            } else {
33
                $this->containerExtension = false;
34
            }
35
        }
36
        return $this->containerExtension ?: null;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->containerExtension ?: null could return the type true which is incompatible with the type-hinted return Symfony\Component\Depend...ExtensionInterface|null. Consider adding an additional type-check to rule them out.
Loading history...
37
    }
38
}
39