Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 38 | class OkFileAwareFileResolver extends AbstractFileResolver implements OkFileAwareFileResolverInterface |
||
| 39 | { |
||
| 40 | |||
| 41 | /** |
||
| 42 | * The appliation instance. |
||
| 43 | * |
||
| 44 | * @var \TechDivision\Import\ApplicationInterface |
||
| 45 | */ |
||
| 46 | private $application; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Initializes the file resolver with the application and the registry instance. |
||
| 50 | * |
||
| 51 | * @param \TechDivision\Import\ApplicationInterface $application The application instance |
||
| 52 | * @param \TechDivision\Import\Services\RegistryProcessorInterface $registryProcessor The registry instance |
||
| 53 | * @param \TechDivision\Import\Loaders\FilteredLoaderInterface $filesystemLoader The filesystem loader instance |
||
| 54 | */ |
||
| 55 | public function __construct( |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Return's the application instance. |
||
| 70 | * |
||
| 71 | * @return \TechDivision\Import\ApplicationInterface The application instance |
||
| 72 | */ |
||
| 73 | 1 | protected function getApplication() : ApplicationInterface |
|
| 77 | |||
| 78 | /** |
||
| 79 | * Remove's the passed line from the file with the passed name. |
||
| 80 | * |
||
| 81 | * @param string $line The line to be removed |
||
| 82 | * @param string $filename The name of the file the line has to be removed |
||
| 83 | * |
||
| 84 | * @return void |
||
| 85 | 1 | * @throws \Exception Is thrown, if the file doesn't exists, the line is not found or can not be removed |
|
| 86 | */ |
||
| 87 | 1 | protected function removeLineFromFile(string $line, string $filename) : void |
|
| 91 | |||
| 92 | /** |
||
| 93 | * Query whether or not the basename, without suffix, of the passed filenames are equal. |
||
| 94 | * |
||
| 95 | 1 | * @param string $filename1 The first filename to compare |
|
| 96 | * @param string $filename2 The second filename to compare |
||
| 97 | * |
||
| 98 | * @return boolean TRUE if the passed files basename are equal, else FALSE |
||
| 99 | 1 | * @todo Refactorig required, because of duplicate method |
|
| 100 | * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::isEqualFilename() |
||
| 101 | */ |
||
| 102 | 1 | protected function isEqualFilename(string $filename1, string $filename2) : bool |
|
| 106 | 1 | ||
| 107 | /** |
||
| 108 | 1 | * Strips the passed suffix, including the (.), from the filename and returns it. |
|
| 109 | * |
||
| 110 | * @param string $filename The filename to return the suffix from |
||
| 111 | * @param string $suffix The suffix to return |
||
| 112 | 1 | * |
|
| 113 | 1 | * @return string The filname without the suffix |
|
| 114 | * @todo Refactorig required, because of duplicate method |
||
| 115 | * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::stripSuffix() |
||
| 116 | */ |
||
| 117 | protected function stripSuffix(string $filename, string $suffix) : string |
||
| 121 | |||
| 122 | /** |
||
| 123 | * Prepares and returns an OK filename from the passed parts. |
||
| 124 | * |
||
| 125 | * @param array $parts The parts to concatenate the OK filename from |
||
| 126 | * |
||
| 127 | * @return string The OK filename |
||
| 128 | 1 | * @todo Refactorig required, because of duplicate method |
|
| 129 | * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::prepareOkFilename() |
||
| 130 | */ |
||
| 131 | protected function prepareOkFilename(array $parts) : string |
||
| 135 | 1 | ||
| 136 | /** |
||
| 137 | * Returns the elements the filenames consists of. |
||
| 138 | 1 | * |
|
| 139 | * @return array The array with the filename elements |
||
| 140 | 1 | * @todo Refactorig required, because of duplicate method |
|
| 141 | * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::getPatternElements() |
||
| 142 | */ |
||
| 143 | protected function getPatternElements() |
||
| 147 | |||
| 148 | /** |
||
| 149 | 1 | * Returns the elements the filenames consists of, converted to lowercase. |
|
| 150 | * |
||
| 151 | 1 | * @return array The array with the filename elements |
|
| 152 | * @todo Refactorig required, because of duplicate method |
||
| 153 | * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::getPatternKeys() |
||
| 154 | */ |
||
| 155 | protected function getPatternKeys() |
||
| 169 | |||
| 170 | /** |
||
| 171 | * Return's an array with the names of the expected OK files for the actual subject. |
||
| 172 | 1 | * |
|
| 173 | 1 | * @return array The array with the expected OK filenames |
|
| 174 | * @todo Refactorig required, because of duplicate method |
||
| 175 | * @see \TechDivision\Import\Loaders\Filters\OkFileFilter::getOkFilenames() |
||
| 176 | */ |
||
| 177 | View Code Duplication | protected function getOkFilenames() : array |
|
| 202 | |||
| 203 | /** |
||
| 204 | * Query whether or not, the passed CSV filename is in the OK file. If the filename was found, |
||
| 205 | * the OK file will be cleaned-up. |
||
| 206 | * |
||
| 207 | * @param string $filename The filename to be cleaned-up |
||
| 208 | * |
||
| 209 | * @return void |
||
| 210 | * @throws \Exception Is thrown, if the passed filename is NOT in the OK file or the OK can not be cleaned-up |
||
| 211 | */ |
||
| 212 | View Code Duplication | public function cleanUpOkFile(string $filename) : void |
|
| 271 | |||
| 272 | /** |
||
| 273 | * Loads the files from the source directory and return's them sorted. |
||
| 274 | * |
||
| 275 | * @param string $serial The unique identifier of the actual import process |
||
| 276 | * |
||
| 277 | * @return array The array with the files matching the subjects suffix |
||
| 278 | * @throws \Exception Is thrown, when the source directory is NOT available |
||
| 279 | * @throws \TechDivision\Import\Exceptions\MissingOkFileException Is thrown, if files to be processed are available but the mandatory OK file is missing |
||
| 280 | */ |
||
| 281 | public function loadFiles(string $serial) : array |
||
| 309 | } |
||
| 310 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.