Conditions | 12 |
Paths | 64 |
Total Lines | 44 |
Code Lines | 21 |
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 |
||
56 | public function __construct($config, $reserved) |
||
57 | { |
||
58 | parent::__construct($config, $reserved); |
||
59 | |||
60 | Assert::isArray($config); |
||
61 | |||
62 | // Check for the deny option |
||
63 | // Must be bool specifically, if not, it might be for an attrib filter below |
||
64 | if (isset($config['deny']) && is_bool($config['deny'])) { |
||
65 | $this->deny = $config['deny']; |
||
66 | } |
||
67 | |||
68 | // Check for the regex option |
||
69 | // Must be bool specifically, if not, it might be for an attrib filter below |
||
70 | if (isset($config['regex']) && is_bool($config['regex'])) { |
||
71 | $this->regex = $config['regex']; |
||
72 | } |
||
73 | |||
74 | // Check for the reject_msg option; Must be array of languages |
||
75 | if (isset($config['reject_msg']) && is_array($config['reject_msg'])) { |
||
76 | $this->reject_msg = $config['reject_msg']; |
||
77 | } |
||
78 | |||
79 | // Remove all above options |
||
80 | unset($config['deny'], $config['regex'], $config['reject_msg']); |
||
81 | |||
82 | foreach ($config as $attribute => $values) { |
||
83 | if (is_string($values)) { |
||
84 | $values = Arrays::arrayize($values); |
||
85 | } else if (!is_array($values)) { |
||
86 | throw new \Exception( |
||
87 | 'Filter Authorize: Attribute values is neither string nor array: '.var_export($attribute, true) |
||
88 | ); |
||
89 | } |
||
90 | |||
91 | foreach ($values as $value) { |
||
92 | if (!is_string($value)) { |
||
93 | throw new \Exception( |
||
94 | 'Filter Authorize: Each value should be a string for attribute: '.var_export($attribute, true). |
||
95 | ' value: '.var_export($value, true).' Config is: '.var_export($config, true) |
||
96 | ); |
||
97 | } |
||
98 | } |
||
99 | $this->valid_attribute_values[$attribute] = $values; |
||
100 | } |
||
165 |