These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace ParamProcessor\Definition; |
||
4 | |||
5 | use ParamProcessor\ParamDefinition; |
||
6 | use ParamProcessor\IParam; |
||
7 | |||
8 | /** |
||
9 | * Defines the string parameter type. |
||
10 | * Specifies the type specific validation and formatting logic. |
||
11 | * |
||
12 | * @deprecated since 1.7 |
||
13 | * |
||
14 | * @licence GNU GPL v2+ |
||
15 | * @author Jeroen De Dauw < [email protected] > |
||
16 | */ |
||
17 | class StringParam extends ParamDefinition { |
||
18 | |||
19 | /** |
||
20 | * Indicates if the parameter should be lowercased post validation. |
||
21 | * |
||
22 | * @since 1.0 |
||
23 | * |
||
24 | * @var boolean |
||
25 | */ |
||
26 | protected $toLower = false; |
||
27 | |||
28 | /** |
||
29 | * Formats the parameter value to it's final result. |
||
30 | * @see ParamDefinition::formatValue |
||
31 | * |
||
32 | * @since 1.0 |
||
33 | * |
||
34 | * @param $value mixed |
||
35 | * @param $param IParam |
||
36 | * @param $definitions array of IParamDefinition |
||
37 | * @param $params array of IParam |
||
38 | * |
||
39 | * @return mixed |
||
40 | */ |
||
41 | 4 | protected function formatValue( $value, IParam $param, array &$definitions, array $params ) { |
|
42 | 4 | $value = (string)$value; |
|
43 | |||
44 | 4 | if ( $this->toLower ) { |
|
45 | $value = strtolower( $value ); |
||
46 | } |
||
47 | |||
48 | 4 | return $value; |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * Sets the parameter definition values contained in the provided array. |
||
53 | * @see ParamDefinition::setArrayValues |
||
54 | * |
||
55 | * @since 1.0 |
||
56 | * |
||
57 | * @param array $param |
||
58 | */ |
||
59 | public function setArrayValues( array $param ) { |
||
60 | parent::setArrayValues( $param ); |
||
0 ignored issues
–
show
|
|||
61 | |||
62 | if ( array_key_exists( 'tolower', $param ) ) { |
||
63 | $this->toLower = $param['tolower']; |
||
64 | } |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Sets of the value should be lowercased. |
||
69 | * |
||
70 | * @since 1.0 |
||
71 | * |
||
72 | * @param boolean $toLower |
||
73 | */ |
||
74 | public function setToLower( $toLower ) { |
||
75 | $this->toLower = $toLower; |
||
76 | } |
||
77 | |||
78 | } |
||
79 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.