| Conditions | 11 |
| Paths | 49 |
| Total Lines | 81 |
| Code Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 57 | public function generate(BundleInterface $bundle, $entityDocument, $metadata, $columns = false) |
||
| 58 | { |
||
| 59 | if ($metadata instanceof ClassMetadataInfo) { |
||
| 60 | $manager = '@doctrine.orm.default_entity_manager'; |
||
| 61 | $class = 'Dtc\GridBundle\Grid\Source\EntityGridSource'; |
||
| 62 | } elseif ($metadata instanceof \Doctrine\ODM\MongoDB\Mapping\ClassMetadataInfo) { |
||
| 63 | $manager = '@doctrine_mongodb.odm.default_document_manager'; |
||
| 64 | $class = 'Dtc\GridBundle\Grid\Source\DocumentGridSource'; |
||
| 65 | } else { |
||
| 66 | throw new \Exception(__METHOD__.' - Unknown class for metadata: '.get_class($metadata)); |
||
| 67 | } |
||
| 68 | $entityDocumentClassPath = $metadata->getReflectionClass()->getName(); |
||
| 69 | |||
| 70 | $parts = explode('\\', $entityDocument); |
||
| 71 | $entityDocumentClass = array_pop($parts); |
||
| 72 | $files = []; |
||
| 73 | |||
| 74 | if ($columns) { |
||
| 75 | list($gridColumnClass, $gridColumnsNamespace, $gridColumnPath, $templatePath) = |
||
| 76 | $this->generateColumns($bundle, $entityDocument, $metadata); |
||
| 77 | |||
| 78 | $files = [ |
||
| 79 | 'grid_columns' => $gridColumnPath, |
||
| 80 | 'grid_template' => $templatePath, |
||
| 81 | ]; |
||
| 82 | } |
||
| 83 | |||
| 84 | // Check to see if the files exists |
||
| 85 | if ($this->saveCache) { |
||
| 86 | foreach ($this->saveCache as $file => $output) { |
||
| 87 | $this->saveFile($file, $output); |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | $config = []; |
||
| 92 | $serviceName = 'grid.source.'.strtolower($entityDocumentClass); |
||
| 93 | $config[$serviceName] = [ |
||
| 94 | 'class' => $class, |
||
| 95 | 'arguments' => [$manager, $entityDocumentClassPath], |
||
| 96 | 'tags' => [['name' => 'dtc_grid.source']], |
||
| 97 | 'calls' => [ |
||
| 98 | ['autoDiscoverColumns'], |
||
| 99 | ], ]; |
||
| 100 | |||
| 101 | if ($columns && isset($gridColumnsNamespace) && isset($gridColumnClass)) { |
||
| 102 | $config[$serviceName]['calls'] = [ |
||
| 103 | ['setColumns', [ |
||
| 104 | '@'.$serviceName.'.columns', |
||
| 105 | ], |
||
| 106 | ], |
||
| 107 | ]; |
||
| 108 | |||
| 109 | $config[$serviceName.'.columns'] = [ |
||
| 110 | 'class' => $gridColumnsNamespace.'\\'.$gridColumnClass, |
||
| 111 | 'arguments' => ['@twig'], |
||
| 112 | ]; |
||
| 113 | } |
||
| 114 | |||
| 115 | $configFile = $bundle->getPath().'/Resources/config/grid.yml'; |
||
| 116 | $services = []; |
||
| 117 | if (file_exists($configFile)) { |
||
| 118 | $services = Yaml::parse($contents = file_get_contents($configFile)); |
||
| 119 | if (isset($services['services'])) { |
||
| 120 | $services['services'] = array_merge($services['services'], $config); |
||
| 121 | } else { |
||
| 122 | $services['services'] = $config; |
||
| 123 | } |
||
| 124 | } else { |
||
| 125 | $services['services'] = $config; |
||
| 126 | } |
||
| 127 | |||
| 128 | $this->saveFile($configFile, Yaml::dump($services, 3)); |
||
| 129 | |||
| 130 | $params = [ |
||
| 131 | 'gridsource_id' => $serviceName, |
||
| 132 | 'files' => $files, |
||
| 133 | ]; |
||
| 134 | |||
| 135 | $output = $this->render($this->skeletonDir, 'controller.php.twig', $params); |
||
| 136 | echo $output; |
||
| 137 | exit(); |
||
| 138 | } |
||
| 176 |
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