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.

FormExtension   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 0
loc 79
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A formHasErrors() 0 4 1
A formValue() 0 7 2
A formCheckboxValue() 0 7 2
A getName() 0 4 1
B getFunctions() 0 35 1
1
<?php
2
3
namespace Application\Twig;
4
5
/**
6
 * @author Borut Balažek <[email protected]>
7
 */
8
class FormExtension extends \Twig_Extension
9
{
10
    /**
11
     * @return string
12
     */
13
    public function getName()
14
    {
15
        return 'application/form';
16
    }
17
18
    /**
19
     * @return \Twig_SimpleFunction[]
20
     */
21
    public function getFunctions()
22
    {
23
        return array(
24
            new \Twig_SimpleFunction(
25
                'form_has_errors',
26
                array(
27
                    $this,
28
                    'formHasErrors',
29
                ),
30
                array(
31
                    'is_safe' => array('html'),
32
                )
33
            ),
34
            new \Twig_SimpleFunction(
35
                'form_value',
36
                array(
37
                    $this,
38
                    'formValue',
39
                ),
40
                array(
41
                    'is_safe' => array('html'),
42
                )
43
            ),
44
            new \Twig_SimpleFunction(
45
                'form_checkbox_value',
46
                array(
47
                    $this,
48
                    'formCheckboxValue',
49
                ),
50
                array(
51
                    'is_safe' => array('html'),
52
                )
53
            ),
54
        );
55
    }
56
57
    /**
58
     * @param bool
59
     */
60
    public function formHasErrors($form)
61
    {
62
        return count($form->vars['errors']) > 0;
63
    }
64
65
    /**
66
     * @return mixed
67
     */
68
    public function formValue($form, $fallback = null)
69
    {
70
        return $form->vars['value']
71
            ? $form->vars['value']
72
            : $fallback
73
        ;
74
    }
75
76
    /**
77
     * @return bool
78
     */
79
    public function formCheckboxValue($form)
80
    {
81
        return $form->vars['checked']
82
            ? true
83
            : false
84
        ;
85
    }
86
}
87