| Conditions | 6 | 
| Paths | 26 | 
| Total Lines | 65 | 
| Code Lines | 35 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 4 | ||
| 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  | 
            ||
| 53 | public function getAssets(AssetType $type, array $assetsCollection, Environment $environment): array  | 
            ||
| 54 |     { | 
            ||
| 55 | $this->cacheTime = $environment->getCacheTime();  | 
            ||
| 56 | |||
| 57 | /** @infection-ignore-all */  | 
            ||
| 58 | $this->filename = '_' . $type->value . DIRECTORY_SEPARATOR . $this->generateHashId(  | 
            ||
| 59 | $assetsCollection  | 
            ||
| 60 | ) . '.' . $type->value;  | 
            ||
| 61 | |||
| 62 | /** @infection-ignore-all */  | 
            ||
| 63 | $this->filePath = $environment->getCompileDir() . DIRECTORY_SEPARATOR . $this->filename;  | 
            ||
| 64 | |||
| 65 | /** @infection-ignore-all */  | 
            ||
| 66 | $this->fileUrl = $environment->getBaseUrl() . '/' . str_replace(DIRECTORY_SEPARATOR, '/', $this->filename);  | 
            ||
| 67 | |||
| 68 | |||
| 69 | $logger = $environment->getLogger();  | 
            ||
| 70 |         $notCollectAssets = array_filter($assetsCollection, function ($asset) { | 
            ||
| 71 | return $asset->getOptions()->isNotCollect();  | 
            ||
| 72 | });  | 
            ||
| 73 | |||
| 74 |         $collectAssets = array_filter($assetsCollection, function ($asset) { | 
            ||
| 75 | return !$asset->getOptions()->isNotCollect();  | 
            ||
| 76 | });  | 
            ||
| 77 | |||
| 78 | $notCollectedResult = (new ManyFilesStrategy())->getAssets($type, $notCollectAssets, $environment);  | 
            ||
| 79 | |||
| 80 | $result = array_merge([  | 
            ||
| 81 | new Asset($type, $this->fileUrl, [  | 
            ||
| 82 | AssetOption::ATTRIBUTES => [  | 
            ||
| 83 | $type->htmlAttribute() => $this->fileUrl  | 
            ||
| 84 | ]  | 
            ||
| 85 | ])  | 
            ||
| 86 | ], $notCollectedResult);  | 
            ||
| 87 | |||
| 88 |         try { | 
            ||
| 89 |             if ($this->isCacheValid()) { | 
            ||
| 90 |                 $logger->info(sprintf('Use cached file: %s', $this->filePath)); | 
            ||
| 91 |                 $logger->info(sprintf('Return url: %s', $this->fileUrl)); | 
            ||
| 92 | return $result;  | 
            ||
| 93 | }  | 
            ||
| 94 | |||
| 95 |             foreach ($collectAssets as $asset) { | 
            ||
| 96 | |||
| 97 | writeFile(  | 
            ||
| 98 | $this->filePath,  | 
            ||
| 99 | (new Reader($asset, $environment))->replaceRelativeUrls()->minify()->getContents(),  | 
            ||
| 100 | 'a'  | 
            ||
| 101 | );  | 
            ||
| 102 | |||
| 103 |                 foreach ($asset->getOptions()->getSymlinks() as $optLink => $optTarget) { | 
            ||
| 104 |                     if (makeSymlink($optLink, $optTarget)) { | 
            ||
| 105 |                         $logger->info(sprintf('Created symlink: %s', $optLink)); | 
            ||
| 106 | }  | 
            ||
| 107 | }  | 
            ||
| 108 | }  | 
            ||
| 109 | |||
| 110 |             $logger->info(sprintf('Write to: %s', $this->filePath)); | 
            ||
| 111 |         } catch (Exception $e) { | 
            ||
| 112 | $logger->notice($e->getMessage());  | 
            ||
| 113 | }  | 
            ||
| 114 | |||
| 115 |         $logger->info(sprintf('Return url: %s', $this->fileUrl)); | 
            ||
| 116 | |||
| 117 | return $result;  | 
            ||
| 118 | }  | 
            ||
| 135 |