CMSMiddlewareServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createCmsMiddleware() 0 3 1
A updatePriorityQueue() 0 4 1
A getFactories() 0 4 1
A getExtensions() 0 4 1
1
<?php
2
3
4
namespace TheCodingMachine\CMS\Middleware;
5
6
7
use Interop\Container\ServiceProvider;
8
use Interop\Container\ServiceProviderInterface;
9
use Psr\Container\ContainerInterface;
10
use TheCodingMachine\CMS\Block\BlockRendererInterface;
11
use TheCodingMachine\CMS\Page\PageRegistryInterface;
12
use TheCodingMachine\CMS\Theme\ThemeFactoryInterface;
13
use TheCodingMachine\MiddlewareListServiceProvider;
14
use TheCodingMachine\MiddlewareOrder;
15
16
class CMSMiddlewareServiceProvider implements ServiceProviderInterface
17
{
18
19
    public function getFactories()
20
    {
21
        return [
22
            CMSMiddleware::class => [self::class, 'createCmsMiddleware'],
23
        ];
24
    }
25
26
    public function getExtensions()
27
    {
28
        return [
29
            MiddlewareListServiceProvider::MIDDLEWARES_QUEUE => [self::class,'updatePriorityQueue'],
30
        ];
31
    }
32
33
34
    public static function createCmsMiddleware(ContainerInterface $container): CMSMiddleware
35
    {
36
        return new CMSMiddleware($container->get(PageRegistryInterface::class), $container->get(BlockRendererInterface::class));
37
    }
38
39
    public static function updatePriorityQueue(ContainerInterface $container, \SplPriorityQueue $queue = null) : \SplPriorityQueue
40
    {
41
        $queue->insert($container->get(CMSMiddleware::class), MiddlewareOrder::ROUTER);
0 ignored issues
show
Bug introduced by
The method insert() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
        $queue->/** @scrutinizer ignore-call */ 
42
                insert($container->get(CMSMiddleware::class), MiddlewareOrder::ROUTER);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
        return $queue;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $queue could return the type null which is incompatible with the type-hinted return SplPriorityQueue. Consider adding an additional type-check to rule them out.
Loading history...
43
    }
44
}
45