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