| Conditions | 20 |
| Paths | 1890 |
| Total Lines | 86 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
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 |
||
| 24 | public function __invoke(OperationCreateEvent $event): void |
||
| 25 | { |
||
| 26 | $operation = $event->getOperation(); |
||
| 27 | $resource = $operation->getResource(); |
||
| 28 | |||
| 29 | if (!$operation->getItemActions()) { |
||
| 30 | $actions = []; |
||
| 31 | |||
| 32 | if ($operation instanceof CollectionOperationInterface) { |
||
| 33 | if ($resource->hasOperation('update')) { |
||
| 34 | $actions[] = new Action( |
||
| 35 | resourceName: $resource->getName(), |
||
| 36 | operationName: 'update', |
||
| 37 | label: 'lag_admin.resource.update', |
||
| 38 | type: 'secondary' |
||
| 39 | ); |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($resource->hasOperation('delete')) { |
||
| 43 | $actions[] = new Action( |
||
| 44 | resourceName: $resource->getName(), |
||
| 45 | operationName: 'delete', |
||
| 46 | label: 'lag_admin.resource.delete', |
||
| 47 | type: 'danger' |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | } else { |
||
| 51 | if ($resource->hasOperation('index')) { |
||
| 52 | $actions[] = new Action( |
||
| 53 | resourceName: $resource->getName(), |
||
| 54 | operationName: 'index', |
||
| 55 | label: 'lag_admin.ui.cancel', |
||
| 56 | type: 'light', |
||
| 57 | ); |
||
| 58 | } |
||
| 59 | } |
||
| 60 | $operation = $operation->withItemActions($actions); |
||
| 61 | } |
||
| 62 | |||
| 63 | if ($operation instanceof CollectionOperationInterface && !$operation->getListActions()) { |
||
| 64 | if ($resource->hasOperation('create')) { |
||
| 65 | $operation = $operation->withListActions([new Action( |
||
| 66 | resourceName: $resource->getName(), |
||
| 67 | operationName: 'create', |
||
| 68 | label: 'lag_admin.ui.create', |
||
| 69 | type: 'primary', |
||
| 70 | )]); |
||
| 71 | } |
||
| 72 | } |
||
| 73 | |||
| 74 | if (!$operation->getTargetRoute()) { |
||
| 75 | if ($resource->hasOperation('index')) { |
||
| 76 | $operation = $operation->withTargetRoute( |
||
| 77 | $this->routeNameGenerator->generateRouteName($resource, $resource->getOperation('index')), |
||
| 78 | ); |
||
| 79 | } |
||
| 80 | } |
||
| 81 | |||
| 82 | if (!$operation->getFormType()) { |
||
| 83 | if ($operation instanceof Create || $operation instanceof Update) { |
||
| 84 | $operation = $operation |
||
| 85 | ->withFormType(OperationDataType::class) |
||
| 86 | ->withFormOptions(['exclude' => $resource->getIdentifiers()]) |
||
| 87 | ; |
||
| 88 | } |
||
| 89 | |||
| 90 | if ($operation instanceof Index && \count($operation->getFilters() ?? []) > 0) { |
||
| 91 | $operation = $operation |
||
| 92 | ->withFormType(ResourceFilterType::class) |
||
| 93 | ; |
||
| 94 | } |
||
| 95 | } |
||
| 96 | |||
| 97 | if (is_a($operation->getFormType(), ResourceFilterType::class, true) && !\array_key_exists('operation', $operation->getFormOptions())) { |
||
| 98 | $operation = $operation->withFormOptions([ |
||
| 99 | 'operation' => $operation, |
||
| 100 | ]); |
||
| 101 | } |
||
| 102 | |||
| 103 | if ($operation instanceof Index) { |
||
| 104 | if ($operation->getListActions() === null) { |
||
| 105 | $operation = $operation->withListActions([]); |
||
| 106 | } |
||
| 107 | } |
||
| 108 | |||
| 109 | $event->setOperation($operation); |
||
| 110 | } |
||
| 112 |
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