| Conditions | 8 |
| Paths | 7 |
| Total Lines | 55 |
| Code Lines | 34 |
| 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 |
||
| 59 | public function handle() |
||
| 60 | { |
||
| 61 | if (!$entityId = $this->option('entityId')) { |
||
| 62 | $this->error('Entity ID must be passed as an option --entityId'); |
||
| 63 | return; |
||
| 64 | } |
||
| 65 | |||
| 66 | if (!$loginUrl = $this->option('loginUrl')) { |
||
| 67 | $this->error('Login URL must be passed as an option --loginUrl'); |
||
| 68 | return; |
||
| 69 | } |
||
| 70 | |||
| 71 | if (!$logoutUrl = $this->option('logoutUrl')) { |
||
| 72 | $this->error('Logout URL must be passed as an option --logoutUrl'); |
||
| 73 | return; |
||
| 74 | } |
||
| 75 | |||
| 76 | if (!$x509cert = $this->option('x509cert')) { |
||
| 77 | $this->error('x509 certificate (base64) must be passed as an option --x509cert'); |
||
| 78 | return; |
||
| 79 | } |
||
| 80 | |||
| 81 | $key = $this->option('key'); |
||
| 82 | $metadata = ConsoleHelper::stringToArray($this->option('metadata')); |
||
| 83 | |||
| 84 | if($key && ($tenant = $this->tenants->findByKey($key))) { |
||
| 85 | $this->renderTenants($tenant, 'Already found tenant(s) using this key'); |
||
| 86 | $this->error( |
||
| 87 | 'Cannot create a tenant because the key is already being associated with other tenants.' |
||
| 88 | . PHP_EOL . 'Firstly, delete tenant(s) or try to create with another with another key.' |
||
| 89 | ); |
||
| 90 | |||
| 91 | return; |
||
| 92 | } |
||
| 93 | |||
| 94 | $tenant = new \Slides\Saml2\Models\Tenant([ |
||
| 95 | 'key' => $key, |
||
| 96 | 'uuid' => \Ramsey\Uuid\Uuid::uuid4(), |
||
| 97 | 'idp_entity_id' => $entityId, |
||
| 98 | 'idp_login_url' => $loginUrl, |
||
| 99 | 'idp_logout_url' => $logoutUrl, |
||
| 100 | 'idp_x509_cert' => $x509cert, |
||
| 101 | 'metadata' => $metadata, |
||
| 102 | ]); |
||
| 103 | |||
| 104 | if(!$tenant->save()) { |
||
| 105 | $this->error('Tenant cannot be saved.'); |
||
| 106 | return; |
||
| 107 | } |
||
| 108 | |||
| 109 | $this->info("The tenant #{$tenant->id} ({$tenant->uuid}) was successfully created."); |
||
| 110 | |||
| 111 | $this->renderTenantCredentials($tenant); |
||
| 112 | |||
| 113 | $this->output->newLine(); |
||
| 114 | } |
||
| 115 | } |
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