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.

TemplateRenderer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 46
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 14 1
A getTemplatePath() 0 4 1
1
<?php
2
3
namespace Dami\Migration;
4
5
use Symfony\Component\Templating\PhpEngine;
6
use Symfony\Component\Templating\TemplateNameParser;
7
use Symfony\Component\Templating\Loader\FilesystemLoader;
8
9
class TemplateRenderer
10
{
11
    private $templateInitialization;
12
13
    /**
14
     * Constructor.
15
     *
16
     * @param TemplateInitialization $templateInitialization TemplateInitialization instance.
17
     */
18
    public function __construct(TemplateInitialization $templateInitialization)
19
    {
20
        $this->templateInitialization = $templateInitialization;
21
    }
22
23
    /**
24
     * Render template
25
     *
26
     * @param string $migrationName Migration name.
27
     *
28
     * @return string Rendered tempalte.
29
     */
30
    public function render($migrationName)
31
    {
32
        $loader = new FilesystemLoader(__DIR__ . '/views/%name%');
0 ignored issues
show
Documentation introduced by
__DIR__ . '/views/%name%' is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
33
34
        $view = new PhpEngine(new TemplateNameParser(), $loader);
35
36
        $this->templateInitialization->setMigrationName($migrationName);
37
38
        return $view->render($this->getTemplatePath(), array(
39
            'migrationName' => $migrationName,
40
            'initUp' => $this->templateInitialization->getInitUp(),
41
            'initDown' => $this->templateInitialization->getInitDown(),
42
        ));
43
    }
44
45
    /**
46
     * Get template path.
47
     *
48
     * @return string Template path.
49
     */
50
    private function getTemplatePath()
51
    {
52
        return __DIR__ . '/Template.php';
53
    }
54
}
55