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::formCheckboxValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 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