Conditions | 40 |
Paths | > 20000 |
Total Lines | 105 |
Code Lines | 68 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
53 | public function __construct(array $params) |
||
54 | { |
||
55 | if (isset($params['calc_size'])) { |
||
56 | $this->bytesPerPart = max(1, intval($params['calc_size'])); |
||
57 | } |
||
58 | if (isset($params['temp_location'])) { |
||
59 | $this->tempDir = strval($params['temp_location']); |
||
60 | } |
||
61 | if (isset($params['target_location'])) { |
||
62 | $this->targetDir = strval($params['target_location']); |
||
63 | } |
||
64 | if (isset($params['lang'])) { |
||
65 | if (is_object($params['lang'])) { |
||
66 | if ($params['lang'] instanceof Interfaces\IUppTranslations) { |
||
67 | $this->lang = $params['lang']; |
||
68 | } |
||
69 | } else { |
||
70 | $this->lang = strval($params['lang']); |
||
71 | } |
||
72 | } |
||
73 | if (isset($params['target'])) { |
||
74 | if (is_object($params['target'])) { |
||
75 | if ($params['target'] instanceof Interfaces\IOperations) { |
||
76 | $this->target = $params['target']; |
||
77 | } |
||
78 | } else { |
||
79 | $this->target = strval($params['target']); |
||
80 | } |
||
81 | } |
||
82 | if (isset($params['data_encoder'])) { |
||
83 | if (is_object($params['data_encoder'])) { |
||
84 | if ($params['data_encoder'] instanceof DrivingFile\DataEncoders\AEncoder) { |
||
85 | $this->dataEncoder = $params['data_encoder']; |
||
86 | } |
||
87 | } else { |
||
88 | $this->dataEncoder = strval($params['data_encoder']); |
||
89 | } |
||
90 | } |
||
91 | if (isset($params['data_modifier'])) { |
||
92 | if (is_object($params['data_modifier'])) { |
||
93 | if ($params['data_modifier'] instanceof DrivingFile\DataModifiers\AModifier) { |
||
94 | $this->dataModifier = $params['data_modifier']; |
||
95 | } |
||
96 | } else { |
||
97 | $this->dataModifier = strval($params['data_modifier']); |
||
98 | } |
||
99 | } |
||
100 | if (isset($params['key_encoder'])) { |
||
101 | if (is_object($params['key_encoder'])) { |
||
102 | if ($params['key_encoder'] instanceof DrivingFile\KeyEncoders\AEncoder) { |
||
103 | $this->keyEncoder = $params['key_encoder']; |
||
104 | } |
||
105 | } else { |
||
106 | $this->keyEncoder = strval($params['key_encoder']); |
||
107 | } |
||
108 | } |
||
109 | if (isset($params['key_modifier'])) { |
||
110 | if (is_object($params['key_modifier'])) { |
||
111 | if ($params['key_modifier'] instanceof DrivingFile\KeyModifiers\AModifier) { |
||
112 | $this->keyModifier = $params['key_modifier']; |
||
113 | } |
||
114 | } else { |
||
115 | $this->keyModifier = strval($params['key_modifier']); |
||
116 | } |
||
117 | } |
||
118 | if (isset($params['driving_file'])) { |
||
119 | if (!is_array($params['driving_file']) && !is_bool($params['driving_file'])) { |
||
120 | $this->drivingFileStorage = $params['driving_file']; |
||
121 | } |
||
122 | } |
||
123 | if (isset($params['temp_storage'])) { |
||
124 | if (!is_array($params['temp_storage']) && !is_bool($params['temp_storage'])) { |
||
125 | $this->temporaryStorage = $params['temp_storage']; |
||
126 | } |
||
127 | } |
||
128 | if (isset($params['temp_encoder'])) { |
||
129 | if (is_object($params['temp_encoder'])) { |
||
130 | if ($params['temp_encoder'] instanceof Local\TemporaryStorage\KeyEncoders\AEncoder) { |
||
131 | $this->temporaryEncoder = $params['temp_encoder']; |
||
132 | } |
||
133 | } else { |
||
134 | $this->temporaryEncoder = strval($params['temp_encoder']); |
||
135 | } |
||
136 | } |
||
137 | if (isset($params['final_storage'])) { |
||
138 | if (!is_array($params['final_storage']) && !is_bool($params['final_storage'])) { |
||
139 | $this->finalStorage = $params['final_storage']; |
||
140 | } |
||
141 | } |
||
142 | if (isset($params['final_encoder'])) { |
||
143 | if (is_object($params['final_encoder'])) { |
||
144 | if ($params['final_encoder'] instanceof Local\FinalStorage\KeyEncoders\AEncoder) { |
||
145 | $this->finalEncoder = $params['final_encoder']; |
||
146 | } |
||
147 | } else { |
||
148 | $this->finalEncoder = strval($params['final_encoder']); |
||
149 | } |
||
150 | } |
||
151 | if (isset($params['checksum'])) { |
||
152 | $this->checksum = strval($params['checksum']); |
||
153 | } |
||
154 | if (isset($params['decoder'])) { |
||
155 | $this->decoder = strval($params['decoder']); |
||
156 | } |
||
157 | $this->canContinue = isset($params['can_continue']) ? boolval(intval(strval($params['can_continue']))) : true; |
||
158 | } |
||
160 |