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.

RequirementLoaderRenderer::render()   B
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 31
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 21
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 21
cts 21
cp 1
rs 8.5806
c 0
b 0
f 0
cc 4
eloc 26
nc 8
nop 6
crap 4
1
<?php
2
3
/*
4
 * This file is part of the Ivory Google Map package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\GoogleMap\Helper\Renderer\Utility;
13
14
use Ivory\GoogleMap\Helper\Renderer\AbstractRenderer;
15
16
/**
17
 * @author GeLo <[email protected]>
18
 */
19
class RequirementLoaderRenderer extends AbstractRenderer
20
{
21
    /**
22
     * @param string      $name
23
     * @param string|null $intervalVariable
24
     * @param string|null $callbackVariable
25
     * @param string|null $requirementVariable
26
     * @param int         $interval
27
     * @param bool        $newLine
28
     *
29
     * @return string
30
     */
31 280
    public function render(
32
        $name,
33
        $intervalVariable = null,
34
        $callbackVariable = null,
35
        $requirementVariable = null,
36
        $interval = 10,
37
        $newLine = true
38
    ) {
39 280
        $formatter = $this->getFormatter();
40
41 280
        $intervalVariable = $intervalVariable ?: 'i';
42 280
        $callbackVariable = $callbackVariable ?: 'c';
43 280
        $requirementVariable = $requirementVariable ?: 'r';
44
45 280
        return $formatter->renderClosure($this->renderRequirement(
46 210
            $intervalVariable,
47 210
            $callbackVariable,
48 210
            $requirementVariable,
49 280
            $formatter->renderStatement('else', $formatter->renderAssignment(
50 280
                'var '.$intervalVariable,
51 280
                $formatter->renderCall('setInterval', [
52 280
                    $formatter->renderClosure($this->renderRequirement(
53 210
                        $intervalVariable,
54 210
                        $callbackVariable,
55 70
                        $requirementVariable
56 140
                    )),
57 280
                    $interval,
58 280
                ], true)
59 280
            ), null, null, false)
60 280
        ), [$callbackVariable, $requirementVariable], $name, true, $newLine);
61
    }
62
63
    /**
64
     * @param string      $intervalVariable
65
     * @param string      $callbackVariable
66
     * @param string      $requirementVariable
67
     * @param string|null $nextStatement
68
     *
69
     * @return string
70
     */
71 280
    private function renderRequirement(
72
        $intervalVariable,
73
        $callbackVariable,
74
        $requirementVariable,
75
        $nextStatement = null
76
    ) {
77 280
        $formatter = $this->getFormatter();
78 280
        $codes = [$formatter->renderCall($callbackVariable, [], true)];
79
80 280
        if (empty($nextStatement)) {
81 280
            array_unshift($codes, $formatter->renderCall('clearInterval', [$intervalVariable], true));
82 140
        }
83
84 280
        return $formatter->renderStatement(
85 280
            'if',
86 280
            $formatter->renderLines($codes, true, false),
87 280
            $formatter->renderCall($requirementVariable),
88 210
            $nextStatement,
89 140
            false
90 140
        );
91
    }
92
}
93