Arrays::getFunctions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 0
cts 11
cp 0
rs 9.7333
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of TwigView.
6
 *
7
 ** (c) 2014 Cees-Jan Kiewiet
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace WyriHaximus\TwigView\Lib\Twig\Extension;
14
15
use Twig\Extension\AbstractExtension;
16
use Twig\TwigFunction;
17
18
/**
19
 * Class Arrays.
20
 * @package WyriHaximus\TwigView\Lib\Twig\Extension
21
 */
22
final class Arrays extends AbstractExtension
23
{
24
    /**
25
     * Get declared functions.
26
     *
27
     * @return \Twig\TwigFunction[]
28
     */
29
    public function getFunctions(): array
30
    {
31
        return [
32
            new TwigFunction('in_array', 'in_array'),
33
            new TwigFunction('explode', 'explode'),
34
            new TwigFunction('array', function ($array) {
35
                return (array)$array;
36
            }),
37
            new TwigFunction('array_push', 'push'),
38
            new TwigFunction('array_add', 'add'),
39
            new TwigFunction('array_prev', 'prev'),
40
            new TwigFunction('array_next', 'next'),
41
            new TwigFunction('array_current', 'current'),
42
            new TwigFunction('array_each', 'each'),
43
        ];
44
    }
45
46
    /**
47
     * Get extension name.
48
     *
49
     * @return string
50
     */
51
    public function getName(): string
52
    {
53
        return 'array';
54
    }
55
}
56