Conditions | 9 |
Paths | 25 |
Total Lines | 80 |
Code Lines | 34 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
81 | public function process() |
||
82 | { |
||
83 | |||
84 | // load the actual status |
||
85 | $status = $this->getRegistryProcessor()->getAttribute(RegistryKeys::STATUS); |
||
86 | |||
87 | // query whether or not the configured source directory is available |
||
88 | if (isset($status[RegistryKeys::SOURCE_DIRECTORY])) { |
||
89 | $sourceDir = $status[RegistryKeys::SOURCE_DIRECTORY]; |
||
90 | } else { |
||
91 | throw new \Exception('Source directory is not available!'); |
||
92 | } |
||
93 | |||
94 | // try to load the archive directory |
||
95 | $archiveDir = $this->getConfiguration()->getArchiveDir(); |
||
96 | |||
97 | // try to initialize a default archive directory by concatenating 'archive' to the target directory |
||
98 | if ($archiveDir === null) { |
||
99 | $archiveDir = sprintf('var/import_history'); |
||
100 | } |
||
101 | |||
102 | // retrieve the question helper |
||
103 | $questionHelper = $this->getHelper('question'); |
||
104 | |||
105 | // initialize the array for the available serials |
||
106 | $availableSerials = array(); |
||
107 | |||
108 | // load the directories from the actual working directory (broken imports, etc.) |
||
109 | foreach (glob(sprintf('%s/*', $sourceDir), GLOB_ONLYDIR) as $possibleImportDir) { |
||
110 | $availableSerials[basename($possibleImportDir)] = filemtime($possibleImportDir); |
||
111 | } |
||
112 | |||
113 | // load the ZIP artefacts from the archive directory |
||
114 | foreach (glob(sprintf('%s/*.zip', $archiveDir)) as $possibleArtefact) { |
||
115 | $availableSerials[ basename($possibleArtefact, '.zip')] = filemtime($possibleArtefact); |
||
116 | } |
||
117 | |||
118 | // sort the available serials |
||
119 | uasort($availableSerials, function ($a, $b) { |
||
120 | // return zero, if the passed values are equal |
||
121 | if ($a == $b) { |
||
122 | return 0; |
||
123 | } |
||
124 | // otherwise return -1 or 1 |
||
125 | return ($a < $b) ? -1 : 1; |
||
126 | }); |
||
127 | |||
128 | // finally create the array with the available serials to render on the console |
||
129 | $availableSerials = array_slice(array_keys($availableSerials), 0, $this->getInput()->getOption(InputOptionKeysInterface::RENDER_DEBUG_SERIALS)); |
||
130 | |||
131 | // this is, when the import:debug send command has been invoked |
||
132 | // WITHOUT the --serial=<UUID> parameter or an invalid serial |
||
133 | if (!in_array($serial = $this->getSerial(), $availableSerials, true)) { |
||
134 | // create the question instance to choose the serial |
||
135 | $chooseSerialQuestion = new ChoiceQuestion('Please select the serial to create the debug artefact for', $availableSerials); |
||
136 | $chooseSerialQuestion->setErrorMessage('Selected serial "%s" is invalid.'); |
||
137 | |||
138 | // abort the operation if the user does not confirm with 'y' or enter |
||
139 | if (!$serial = $questionHelper->ask($this->getInput(), $this->getOutput(), $chooseSerialQuestion)) { |
||
140 | $this->getOutput()->writeln('<info>Aborting operation - debug report has NOT been sent.</info>'); |
||
141 | return; |
||
142 | } |
||
143 | } |
||
144 | |||
145 | // update the registry with the (probably new) serial and the source directory |
||
146 | $this->getRegistryProcessor()->mergeAttributesRecursive( |
||
147 | RegistryKeys::STATUS, |
||
148 | array( |
||
149 | RegistryKeys::DEBUG_SERIAL => $serial, |
||
150 | RegistryKeys::SOURCE_DIRECTORY => sprintf('%s/%s', $sourceDir, $serial) |
||
151 | ) |
||
152 | ); |
||
153 | |||
154 | // prepare the debug dump |
||
155 | $this->getDebugUtil()->extractArchive($serial); |
||
156 | $this->getDebugUtil()->prepareDump($serial); |
||
157 | $dumpFilename = $this->getDebugUtil()->createDump($serial); |
||
158 | |||
159 | // write a success message to the console |
||
160 | $this->getOutput()->writeln(sprintf('<info>Successfully created debug dump "%s"</info>', $dumpFilename)); |
||
161 | } |
||
163 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths