Conditions | 9 |
Paths | 19 |
Total Lines | 53 |
Code Lines | 35 |
Lines | 5 |
Ratio | 9.43 % |
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 |
||
86 | public function make($list, $fixed_options, $options) |
||
87 | { |
||
88 | Configure::write('debug', 0); |
||
89 | ini_set("memory_limit", -1); |
||
90 | set_time_limit(0); |
||
91 | |||
92 | $this->_textData = ''; |
||
93 | $options = array_merge($this->_defaultOptions,$options); |
||
94 | extract($options); |
||
95 | |||
96 | mb_convert_variables($export_encoding, $array_encoding, $list); |
||
97 | |||
98 | // keyを振りなおしておく。 |
||
99 | $list = array_merge($list); |
||
100 | $list_count = count($list); |
||
101 | //$listにカンマか"がいた時の対応 |
||
102 | $return_text = ''; |
||
103 | foreach ($list as $row => $list_val) { |
||
104 | $column_options = $fixed_options; |
||
105 | View Code Duplication | if (array_key_exists($row + 1, $extra_fixed_options)) { |
|
106 | $column_options = $extra_fixed_options[$row + 1]; |
||
107 | } elseif (array_key_exists($row - $list_count, $extra_fixed_options)) { |
||
108 | $column_options = $extra_fixed_options[$row - $list_count]; |
||
109 | } |
||
110 | |||
111 | foreach ($column_options as $fixed_option_key => $fixed_info) { |
||
112 | if (!array_key_exists($fixed_option_key, $list_val)) { |
||
113 | //必要なデータが存在しないエラー |
||
114 | throw new MethodNotAllowedException('data not exist'); |
||
115 | } else if (strlen($list_val[$fixed_option_key]) > $fixed_info['length']) { |
||
116 | throw new MethodNotAllowedException('length error'); |
||
117 | } |
||
118 | |||
119 | if ($fixed_info['type'] == 'text') { |
||
120 | $return_text .= str_pad($list_val[$fixed_option_key], $fixed_info['length']); |
||
121 | } elseif ($fixed_info['type'] == 'integer') { |
||
122 | $return_text .= sprintf('%0' . $fixed_info['length'] . 's', ($list_val[$fixed_option_key])); |
||
123 | } else { |
||
124 | throw new MethodNotAllowedException('type error'); |
||
125 | } |
||
126 | } |
||
127 | $return_text .= $line_feed_code; |
||
128 | } |
||
129 | |||
130 | $this->_textData = $return_text; |
||
131 | $save_directory = $directory . $file_name; |
||
132 | $fp = fopen($save_directory, 'w'); |
||
133 | fwrite($fp, $return_text); |
||
134 | |||
135 | fclose($fp); |
||
136 | |||
137 | return $save_directory; |
||
138 | } |
||
139 | |||
148 |
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.