| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 146 | 
| Code Lines | 105 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php | ||
| 26 | public function dataOptions(): array | ||
| 27 |     { | ||
| 28 | return [ | ||
| 29 | [ | ||
| 30 | new GreaterThan(1), | ||
| 31 | [ | ||
| 32 | 'targetValue' => 1, | ||
| 33 | 'targetAttribute' => null, | ||
| 34 | 'incorrectInputMessage' => [ | ||
| 35 | 'template' => 'The allowed types are integer, float, string, boolean and null.', | ||
| 36 | 'parameters' => [ | ||
| 37 | 'targetValue' => 1, | ||
| 38 | 'targetAttribute' => null, | ||
| 39 | 'targetValueOrAttribute' => 1, | ||
| 40 | ], | ||
| 41 | ], | ||
| 42 | 'incorrectDataSetTypeMessage' => [ | ||
| 43 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', | ||
| 44 | 'parameters' => [ | ||
| 45 | 'targetValue' => 1, | ||
| 46 | 'targetAttribute' => null, | ||
| 47 | 'targetValueOrAttribute' => 1, | ||
| 48 | ], | ||
| 49 | ], | ||
| 50 | 'message' => [ | ||
| 51 |                         'template' => 'Value must be greater than "{targetValueOrAttribute}".', | ||
| 52 | 'parameters' => [ | ||
| 53 | 'targetValue' => 1, | ||
| 54 | 'targetAttribute' => null, | ||
| 55 | 'targetValueOrAttribute' => 1, | ||
| 56 | ], | ||
| 57 | ], | ||
| 58 | 'type' => 'string', | ||
| 59 | 'operator' => '>', | ||
| 60 | 'skipOnEmpty' => false, | ||
| 61 | 'skipOnError' => false, | ||
| 62 | ], | ||
| 63 | ], | ||
| 64 | [ | ||
| 65 | new GreaterThan(1, type: CompareType::NUMBER), | ||
| 66 | [ | ||
| 67 | 'targetValue' => 1, | ||
| 68 | 'targetAttribute' => null, | ||
| 69 | 'incorrectInputMessage' => [ | ||
| 70 | 'template' => 'The allowed types are integer, float, string, boolean and null.', | ||
| 71 | 'parameters' => [ | ||
| 72 | 'targetValue' => 1, | ||
| 73 | 'targetAttribute' => null, | ||
| 74 | 'targetValueOrAttribute' => 1, | ||
| 75 | ], | ||
| 76 | ], | ||
| 77 | 'incorrectDataSetTypeMessage' => [ | ||
| 78 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', | ||
| 79 | 'parameters' => [ | ||
| 80 | 'targetValue' => 1, | ||
| 81 | 'targetAttribute' => null, | ||
| 82 | 'targetValueOrAttribute' => 1, | ||
| 83 | ], | ||
| 84 | ], | ||
| 85 | 'message' => [ | ||
| 86 |                         'template' => 'Value must be greater than "{targetValueOrAttribute}".', | ||
| 87 | 'parameters' => [ | ||
| 88 | 'targetValue' => 1, | ||
| 89 | 'targetAttribute' => null, | ||
| 90 | 'targetValueOrAttribute' => 1, | ||
| 91 | ], | ||
| 92 | ], | ||
| 93 | 'type' => 'number', | ||
| 94 | 'operator' => '>', | ||
| 95 | 'skipOnEmpty' => false, | ||
| 96 | 'skipOnError' => false, | ||
| 97 | ], | ||
| 98 | ], | ||
| 99 | [ | ||
| 100 | new GreaterThan(null, 'attribute'), | ||
| 101 | [ | ||
| 102 | 'targetValue' => null, | ||
| 103 | 'targetAttribute' => 'attribute', | ||
| 104 | 'incorrectInputMessage' => [ | ||
| 105 | 'template' => 'The allowed types are integer, float, string, boolean and null.', | ||
| 106 | 'parameters' => [ | ||
| 107 | 'targetValue' => null, | ||
| 108 | 'targetAttribute' => 'attribute', | ||
| 109 | 'targetValueOrAttribute' => 'attribute', | ||
| 110 | ], | ||
| 111 | ], | ||
| 112 | 'incorrectDataSetTypeMessage' => [ | ||
| 113 | 'template' => 'The attribute value returned from a custom data set must have a scalar type.', | ||
| 114 | 'parameters' => [ | ||
| 115 | 'targetValue' => null, | ||
| 116 | 'targetAttribute' => 'attribute', | ||
| 117 | 'targetValueOrAttribute' => 'attribute', | ||
| 118 | ], | ||
| 119 | ], | ||
| 120 | 'message' => [ | ||
| 121 |                         'template' => 'Value must be greater than "{targetValueOrAttribute}".', | ||
| 122 | 'parameters' => [ | ||
| 123 | 'targetValue' => null, | ||
| 124 | 'targetAttribute' => 'attribute', | ||
| 125 | 'targetValueOrAttribute' => 'attribute', | ||
| 126 | ], | ||
| 127 | ], | ||
| 128 | 'type' => 'string', | ||
| 129 | 'operator' => '>', | ||
| 130 | 'skipOnEmpty' => false, | ||
| 131 | 'skipOnError' => false, | ||
| 132 | ], | ||
| 133 | ], | ||
| 134 | [ | ||
| 135 | new GreaterThan( | ||
| 136 | targetAttribute: 'test', | ||
| 137 | incorrectInputMessage: 'Custom message 1.', | ||
| 138 | incorrectDataSetTypeMessage: 'Custom message 2.', | ||
| 139 | message: 'Custom message 3.', | ||
| 140 | ), | ||
| 141 | [ | ||
| 142 | 'targetValue' => null, | ||
| 143 | 'targetAttribute' => 'test', | ||
| 144 | 'incorrectInputMessage' => [ | ||
| 145 | 'template' => 'Custom message 1.', | ||
| 146 | 'parameters' => [ | ||
| 147 | 'targetValue' => null, | ||
| 148 | 'targetAttribute' => 'test', | ||
| 149 | 'targetValueOrAttribute' => 'test', | ||
| 150 | ], | ||
| 151 | ], | ||
| 152 | 'incorrectDataSetTypeMessage' => [ | ||
| 153 | 'template' => 'Custom message 2.', | ||
| 154 | 'parameters' => [ | ||
| 155 | 'targetValue' => null, | ||
| 156 | 'targetAttribute' => 'test', | ||
| 157 | 'targetValueOrAttribute' => 'test', | ||
| 158 | ], | ||
| 159 | ], | ||
| 160 | 'message' => [ | ||
| 161 | 'template' => 'Custom message 3.', | ||
| 162 | 'parameters' => [ | ||
| 163 | 'targetValue' => null, | ||
| 164 | 'targetAttribute' => 'test', | ||
| 165 | 'targetValueOrAttribute' => 'test', | ||
| 166 | ], | ||
| 167 | ], | ||
| 168 | 'type' => 'string', | ||
| 169 | 'operator' => '>', | ||
| 170 | 'skipOnEmpty' => false, | ||
| 171 | 'skipOnError' => false, | ||
| 172 | ], | ||
| 207 |