BaseDataSource   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
eloc 12
c 1
b 0
f 1
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerAsTwigFunction() 0 3 1
A getFunctions() 0 18 4
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Everlution\AjaxcomBundle\DataSource;
6
7
/**
8
 * Class BaseDataSource.
9
 *
10
 * @author Ivan Barlog <[email protected]>
11
 */
12
class BaseDataSource extends \Twig_Extension
0 ignored issues
show
Bug introduced by
The type Twig_Extension 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...
13
{
14
    protected const TWIG_FUNCTION_SUFFIX = 'Provider';
15
16
    /**
17
     * @return array
18
     */
19
    public function getFunctions()
20
    {
21
        $functions = [];
22
        $class = new \ReflectionClass(get_class($this));
23
24
        if (self::class === $class->name) {
25
            return $functions;
26
        }
27
28
        foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
29
            if (false === ($offset = strpos($method->getName(), self::TWIG_FUNCTION_SUFFIX))) {
30
                continue;
31
            }
32
33
            $functions[] = $this->registerAsTwigFunction(substr($method->getName(), 0, $offset));
34
        }
35
36
        return $functions;
37
    }
38
39
    private function registerAsTwigFunction(string $name): ?\Twig_SimpleFunction
0 ignored issues
show
Bug introduced by
The type Twig_SimpleFunction 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...
40
    {
41
        return new \Twig_SimpleFunction($name, [$this, $name.self::TWIG_FUNCTION_SUFFIX]);
42
    }
43
}
44