GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 6a0f46...ee4e74 )
by Matthias
03:03
created

ShortcodeDefinitionTestHelper::getHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Webfactory\ShortcodeBundle\Test;
4
5
use RuntimeException;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
8
use Thunder\Shortcode\HandlerContainer\HandlerContainerInterface;
9
use Webfactory\ShortcodeBundle\Handler\EmbeddedShortcodeHandler;
10
11
/**
12
 * Helper class that you can use in functional (end-to-end) tests to verify that a given
13
 * content with shortcodes is processed as expected.
14
 */
15
class ShortcodeDefinitionTestHelper
16
{
17
    /**
18
     * @var ControllerResolverInterface
19
     */
20
    private $controllerResolver;
21
22
    /**
23
     * @var HandlerContainerInterface
24
     */
25
    private $handlerContainer;
26
27
    public function __construct(ControllerResolverInterface $controllerResolver, HandlerContainerInterface $handlerContainer)
28
    {
29
        $this->handlerContainer = $handlerContainer;
30
        $this->controllerResolver = $controllerResolver;
31
    }
32
33
    public function hasShortcode(string $shortcode): bool
34
    {
35
        return null !== $this->handlerContainer->get($shortcode);
36
    }
37
38
    public function getHandler(string $shortcode): callable
39
    {
40
        return $this->handlerContainer->get($shortcode);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->handlerContainer->get($shortcode) could return the type null which is incompatible with the type-hinted return callable. Consider adding an additional type-check to rule them out.
Loading history...
41
    }
42
43
    /**
44
     * @return callable-array
0 ignored issues
show
Documentation Bug introduced by
The doc comment callable-array at position 0 could not be parsed: Unknown type name 'callable-array' at position 0 in callable-array.
Loading history...
45
     */
46
    public function resolveShortcodeController(string $shortcode): array
47
    {
48
        $handler = $this->handlerContainer->get($shortcode);
49
50
        if (!$handler instanceof EmbeddedShortcodeHandler) {
51
            throw new RuntimeException('In order to test resolution of shortcodes to Controllers, the handler must be an instance of EmbeddedShortcodeHandler');
52
        }
53
54
        return $this->controllerResolver->getController(new Request([], [], ['_controller' => $handler->getControllerName()]));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->controller...>getControllerName()))) returns the type callable|false which is incompatible with the type-hinted return array.
Loading history...
55
    }
56
}
57