Conditions | 3 |
Paths | 4 |
Total Lines | 55 |
Code Lines | 40 |
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 |
||
122 | protected function export() |
||
123 | { |
||
124 | $filesystem = new Filesystem(); |
||
125 | $handle = fopen($this->config['path'] . $this->prefix, "w"); |
||
126 | |||
127 | $checkPermissions = true; |
||
128 | if (PHP_SAPI == 'cli') { |
||
129 | $checkPermissions = false; |
||
130 | } |
||
131 | |||
132 | if (!$this->export->Init( |
||
133 | $handle, |
||
134 | $this->config["id"], |
||
135 | false, |
||
136 | true, |
||
137 | $this->session["work_dir"], |
||
138 | $this->session["file_dir"], |
||
139 | $checkPermissions |
||
140 | ) |
||
141 | ) { |
||
142 | throw new ExportException('Failed to initialize export'); |
||
143 | } |
||
144 | |||
145 | $this->export->DoNotDownloadCloudFiles(); |
||
146 | $this->export->StartExport(); |
||
147 | |||
148 | $this->export->StartExportMetadata(); |
||
149 | $this->export->ExportProperties($this->session["property_map"]); |
||
150 | $this->export->ExportSections( |
||
151 | $this->session["section_map"], |
||
152 | time(), |
||
153 | $this->config['interval'], |
||
154 | $this->config["sections"], |
||
155 | $this->session["property_map"] |
||
156 | ); |
||
157 | $this->export->EndExportMetadata(); |
||
158 | |||
159 | $this->export->StartExportCatalog(); |
||
160 | $this->export->ExportElements( |
||
161 | $this->session["property_map"], |
||
162 | $this->session["section_map"], |
||
163 | time(), |
||
164 | $this->config['interval'], |
||
165 | 0, |
||
166 | $this->config["elements"] |
||
167 | ); |
||
168 | $this->export->EndExportCatalog(); |
||
169 | |||
170 | $this->export->ExportProductSets(); |
||
171 | $this->export->EndExport(); |
||
172 | |||
173 | fclose($handle); |
||
174 | $filesystem->remove($this->config['path']); |
||
175 | $filesystem->rename($this->config['path'] . $this->prefix, $this->config['path'], true); |
||
176 | } |
||
177 | } |