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