Passed
Push — 4.1 ( cc1509...e0bb47 )
by Andrea
12:41
created

UtilitaExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 25%

Importance

Changes 0
Metric Value
wmc 4
eloc 11
dl 0
loc 34
ccs 3
cts 12
cp 0.25
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A remoteFileExists() 0 8 2
A getDb2data() 0 5 1
A getFunctions() 0 5 1
1
<?php
2
3
namespace Fi\CoreBundle\Twig\Extension;
4
5
use Fi\CoreBundle\Controller\FiUtilita;
0 ignored issues
show
Bug introduced by
The type Fi\CoreBundle\Controller\FiUtilita 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
class UtilitaExtension extends \Twig_Extension
8
{
9
10
    /**
11
     * {@inheritdoc}
12
     */
13 1
    public function getFunctions()
14
    {
15
        return array(
16 1
            new \Twig_SimpleFunction('db2data', array($this, 'getDb2data', 'is_safe' => array('html'))),
17 1
            new \Twig_SimpleFunction('remote_file_exists', array($this, 'remoteFileExists', 'is_safe' => array('html'))),
18
        );
19
    }
20
21
    public function getDb2data($giorno)
22
    {
23
        // highlight_string highlights php code only if '<?php' tag is present.
24
25
        return FiUtilita::db2data($giorno, true);
26
    }
27
28
    /**
29
     * @param string $url
30
     *
31
     * @return bool
32
     */
33
    public function remoteFileExists($url)
34
    {
35
        $ch = curl_init($url);
36
        curl_setopt($ch, CURLOPT_NOBODY, true);
37
        curl_exec($ch);
38
        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
39
        curl_close($ch);
40
        return $status === 200 ? true : false;
41
    }
42
}
43