Passed
Push — v5.x ( 6ac3c7...223ede )
by Thierry
02:17
created

ParameterFactory::input()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * ParameterFactory.php - Jaxon Call Factory
5
 *
6
 * Create js parameters for calls to Jaxon classes.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2016 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-core
13
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
14
15
namespace Jaxon\Js;
16
17
class ParameterFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ParameterFactory
Loading history...
18
{
19
    /**
20
     * Make a parameter of type Parameter::FORM_VALUES
21
     *
22
     * @param string $sFormId    The id of the HTML form
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
23
     *
24
     * @return Parameter
25
     */
26
    public function form(string $sFormId): Parameter
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
27
    {
28
        return new Parameter(Parameter::FORM_VALUES, $sFormId);
29
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
30
31
    /**
32
     * Make a parameter of type Parameter::INPUT_VALUE
33
     *
34
     * @param string $sInputId    the id of the HTML input element
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
35
     *
36
     * @return Parameter
37
     */
38
    public function input(string $sInputId): Parameter
39
    {
40
        return new Parameter(Parameter::INPUT_VALUE, $sInputId);
41
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
42
43
    /**
44
     * Make a parameter of type Parameter::CHECKED_VALUE
45
     *
46
     * @param string $sInputId    the name of the HTML form element
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
47
     *
48
     * @return Parameter
49
     */
50
    public function checked(string $sInputId): Parameter
51
    {
52
        return new Parameter(Parameter::CHECKED_VALUE, $sInputId);
53
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
54
55
    /**
56
     * Make a parameter of type Parameter::CHECKED_VALUE
57
     *
58
     * @param string $sInputId    the name of the HTML form element
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
59
     *
60
     * @return Parameter
61
     */
62
    public function select(string $sInputId): Parameter
63
    {
64
        return $this->input($sInputId);
65
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
66
67
    /**
68
     * Make a parameter of type Parameter::ELEMENT_INNERHTML
69
     *
70
     * @param string $sElementId    the id of the HTML element
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
71
     *
72
     * @return Parameter
73
     */
74
    public function html(string $sElementId): Parameter
75
    {
76
        return new Parameter(Parameter::ELEMENT_INNERHTML, $sElementId);
77
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
78
79
    /**
80
     * Make a parameter of type Parameter::QUOTED_VALUE
81
     *
82
     * @param string $sValue    the value of the parameter
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
83
     *
84
     * @return Parameter
85
     */
86
    public function string(string $sValue): Parameter
87
    {
88
        return new Parameter(Parameter::QUOTED_VALUE, $sValue);
89
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
90
91
    /**
92
     * Make a parameter of type Parameter::NUMERIC_VALUE
93
     *
94
     * @param int $nValue    the value of the parameter
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
95
     *
96
     * @return Parameter
97
     */
98
    public function numeric(int $nValue): Parameter
99
    {
100
        return new Parameter(Parameter::NUMERIC_VALUE, intval($nValue));
101
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
102
103
    /**
104
     * Make a parameter of type Parameter::NUMERIC_VALUE
105
     *
106
     * @param numeric $nValue    the value of the parameter
0 ignored issues
show
Bug introduced by
The type Jaxon\Js\numeric 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...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
107
     *
108
     * @return Parameter
109
     */
110
    public function int(int $nValue): Parameter
111
    {
112
        return $this->numeric($nValue);
113
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
114
115
    /**
116
     * Make a parameter of type Parameter::JS_VALUE
117
     *
118
     * @param string $sValue    the javascript code of the parameter
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
119
     *
120
     * @return Parameter
121
     */
122
    public function javascript(string $sValue): Parameter
123
    {
124
        return new Parameter(Parameter::JS_VALUE, $sValue);
125
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
126
127
    /**
128
     * Make a parameter of type Parameter::JS_VALUE
129
     *
130
     * @param string $sValue    the javascript code of the parameter
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
131
     *
132
     * @return Parameter
133
     */
134
    public function js(string $sValue): Parameter
135
    {
136
        return $this->javascript($sValue);
137
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
138
139
    /**
140
     * Make a parameter of type Parameter::PAGE_NUMBER
141
     *
142
     * @return Parameter
143
     */
144
    public function page(): Parameter
145
    {
146
        // By default, the value of a parameter of type Parameter::PAGE_NUMBER is 0.
147
        return new Parameter(Parameter::PAGE_NUMBER, 0);
148
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
149
}
150