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