| Conditions | 11 |
| Paths | 12 |
| Total Lines | 36 |
| Code Lines | 23 |
| 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 |
||
| 72 | private function updateHtmlFiles(): void |
||
| 73 | { |
||
| 74 | $sql = "SELECT iid, resource_node_id FROM c_document WHERE filetype = 'file'"; |
||
| 75 | $result = $this->connection->executeQuery($sql); |
||
| 76 | $items = $result->fetchAllAssociative(); |
||
| 77 | |||
| 78 | $documentRepo = $this->container->get(CDocumentRepository::class); |
||
| 79 | $resourceNodeRepo = $this->container->get(ResourceNodeRepository::class); |
||
| 80 | |||
| 81 | foreach ($items as $item) { |
||
| 82 | /** @var CDocument $document */ |
||
| 83 | $document = $documentRepo->find($item['iid']); |
||
| 84 | if (!$document) { |
||
| 85 | continue; |
||
| 86 | } |
||
| 87 | |||
| 88 | $resourceNode = $document->getResourceNode(); |
||
| 89 | if (!$resourceNode || !$resourceNode->hasResourceFile()) { |
||
| 90 | continue; |
||
| 91 | } |
||
| 92 | |||
| 93 | $resourceFile = $resourceNode->getResourceFiles()->first(); |
||
| 94 | if (!$resourceFile || $resourceFile->getMimeType() !== 'text/html') { |
||
| 95 | continue; |
||
| 96 | } |
||
| 97 | |||
| 98 | try { |
||
| 99 | $content = $resourceNodeRepo->getResourceNodeFileContent($resourceNode); |
||
| 100 | if (is_string($content) && trim($content) !== '') { |
||
| 101 | $updatedContent = $this->replaceGifWithPng($content); |
||
| 102 | if ($content !== $updatedContent) { |
||
| 103 | $documentRepo->updateResourceFileContent($document, $updatedContent); |
||
| 104 | $documentRepo->update($document); |
||
| 105 | } |
||
| 106 | } |
||
| 107 | } catch (Exception $e) { |
||
| 108 | // error_log("Error processing file for document ID {$item['iid']}: " . $e->getMessage()); |
||
| 126 |
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.