TwigExtension::getName()   A
last analyzed

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
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Dtc\GridBundle\Twig\Extension;
4
5
class TwigExtension extends \Twig\Extension\AbstractExtension
0 ignored issues
show
Bug introduced by
The type Twig\Extension\AbstractExtension was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
{
7
    public function getFunction()
8
    {
9
        $names = [
10
            'format_cell' => 'format_cell',
11
        ];
12
13
        $funcs = [];
14
        foreach ($names as $twig => $local) {
15
            $funcs[$twig] = new \Twig\TwigFunction($twig, [$this, $local]);
0 ignored issues
show
Bug introduced by
The type Twig\TwigFunction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
        }
17
18
        return $funcs;
19
    }
20
21
    public function getFilters()
22
    {
23
        $names = [
24
            'format_cell' => 'format_cell',
25
        ];
26
27
        $funcs = [];
28
        foreach ($names as $twig => $local) {
29
            $funcs[$twig] = new \Twig\TwigFilter($twig, [$this, $local]);
0 ignored issues
show
Bug introduced by
The type Twig\TwigFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
        }
31
32
        return $funcs;
33
    }
34
35
    public function getName()
36
    {
37
        return 'dtc_grid';
38
    }
39
40
    public function format_cell($value)
41
    {
42
        if (is_object($value)) {
43
            if ($value instanceof \DateTime) {
44
                return $value->format(\DateTime::ISO8601);
45
            }
46
47
            return 'object: '.get_class($value);
48
        } elseif (is_scalar($value)) {
49
            return $value;
50
        } elseif (is_array($value)) {
51
            return 'array';
52
        }
53
    }
54
}
55