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.
Passed
Push — master ( b43f4a...009a79 )
by Mewes
10:25
created

TwigSpreadsheetExtension::getNodeVisitors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace MewesK\TwigSpreadsheetBundle\Twig;
4
5
use MewesK\TwigSpreadsheetBundle\Twig\NodeVisitor\MacroContextNodeVisitor;
6
use MewesK\TwigSpreadsheetBundle\Twig\NodeVisitor\SyntaxCheckNodeVisitor;
7
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\AlignmentTokenParser;
8
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\CellTokenParser;
9
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\DocumentTokenParser;
10
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\DrawingTokenParser;
11
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\HeaderFooterTokenParser;
12
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\RowTokenParser;
13
use MewesK\TwigSpreadsheetBundle\Twig\TokenParser\SheetTokenParser;
14
use MewesK\TwigSpreadsheetBundle\Wrapper\HeaderFooterWrapper;
15
16
/**
17
 * Class TwigSpreadsheetExtension.
18
 */
19
class TwigSpreadsheetExtension extends \Twig_Extension
20
{
21
    /**
22
     * @var array
23
     */
24
    private $attributes;
25
26
    /**
27
     * TwigSpreadsheetExtension constructor.
28
     *
29
     * @param array $attributes
30
     */
31 26
    public function __construct(array $attributes = [])
32
    {
33 26
        $this->attributes = $attributes;
34 26
    }
35
36
    /**
37
     * @return array
38
     */
39 2
    public function getAttributes(): array
40
    {
41 2
        return $this->attributes;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 8
    public function getFunctions()
48
    {
49
        return [
50 8
            new \Twig_SimpleFunction('xlsmergestyles', [$this, 'mergeStyles']),
51
        ];
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     *
57
     * @throws \InvalidArgumentException
58
     */
59 8
    public function getTokenParsers()
60
    {
61
        return [
62 8
            new AlignmentTokenParser([], HeaderFooterWrapper::ALIGNMENT_CENTER),
63 8
            new AlignmentTokenParser([], HeaderFooterWrapper::ALIGNMENT_LEFT),
64 8
            new AlignmentTokenParser([], HeaderFooterWrapper::ALIGNMENT_RIGHT),
65 8
            new CellTokenParser(),
66 8
            new DocumentTokenParser($this->attributes),
67 8
            new DrawingTokenParser(),
68 8
            new HeaderFooterTokenParser([], HeaderFooterWrapper::BASETYPE_FOOTER),
69 8
            new HeaderFooterTokenParser([], HeaderFooterWrapper::BASETYPE_HEADER),
70 8
            new RowTokenParser(),
71 8
            new SheetTokenParser(),
72
        ];
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 8
    public function getNodeVisitors()
79
    {
80
        return [
81 8
            new MacroContextNodeVisitor(),
82 8
            new SyntaxCheckNodeVisitor(),
83
        ];
84
    }
85
86
    /**
87
     * @param array $style1
88
     * @param array $style2
89
     *
90
     * @throws \Twig_Error_Runtime
91
     *
92
     * @return array
93
     */
94
    public function mergeStyles(array $style1, array $style2): array
95
    {
96
        if (!is_array($style1) || !is_array($style2)) {
97
            throw new \Twig_Error_Runtime('The xlsmergestyles function only works with arrays.');
98
        }
99
100
        return array_merge_recursive($style1, $style2);
101
    }
102
}
103