| Conditions | 8 |
| Paths | 24 |
| Total Lines | 66 |
| Code Lines | 41 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 21 | } |
||
| 22 | } |
||
| 23 | |||
| 24 | // Actually I have my own oauth token cache based authentication guard now lol |
||
| 25 | config(['auth.guards.api.driver' => 'oauthtoken']); |
||
| 26 | Auth::extend('oauthtoken', function ($app, $name, array $config) { |
||
| 27 | return new OauthTokenGuard(Auth::createUserProvider($config['provider']), $app->make('request')); |
||
|
|
|||
| 28 | }); |
||
| 29 | |||
| 30 | // Make sure that this vendor dir and the routes dir are in any scanned paths for swagger documentation |
||
| 31 | $swaggerScanPaths = config('l5-swagger.paths.annotations'); |
||
| 32 | if (! is_array($swaggerScanPaths)) { |
||
| 33 | $swaggerScanPaths = [$swaggerScanPaths]; |
||
| 34 | } |
||
| 35 | if (! in_array(base_path('routes'), $swaggerScanPaths)) { |
||
| 36 | $swaggerScanPaths[] = base_path('routes'); |
||
| 37 | } |
||
| 38 | if (! in_array(__DIR__.'/../routes/', $swaggerScanPaths)) { |
||
| 39 | $swaggerScanPaths[] = __DIR__.'/../routes/'; |
||
| 40 | } |
||
| 41 | config(['l5-swagger.paths.annotations' => $swaggerScanPaths]); |
||
| 42 | |||
| 43 | // Make sure the publish command picks up our config, migration, user model, and dummy API route files |
||
| 44 | $this->publishes([ |
||
| 45 | __DIR__.'/../publish/config/enterpriseauth.php' => config_path('enterpriseauth.php'), |
||
| 46 | __DIR__.'/../publish/database/migrations/2018_02_19_152839_alter_users_table_for_azure_ad.php' => $this->app->databasePath().'/migrations/2018_02_19_152839_alter_users_table_for_azure_ad.php', |
||
| 47 | __DIR__.'/../publish/app/User.php' => app_path().'/User.php', |
||
| 48 | __DIR__.'/../publish/routes/api.php' => base_path('routes').'/api.php', |
||
| 49 | ]); |
||
| 50 | |||
| 51 | // Merge configs with the default configs |
||
| 52 | $this->mergeConfigFrom( |
||
| 53 | __DIR__.'/../publish/config/enterpriseauth.php', 'enterpriseauth' |
||
| 54 | ); |
||
| 55 | |||
| 56 | // Load our HTTP routes for API and WEB authentication |
||
| 57 | $this->loadRoutesFrom(__DIR__.'/../routes/api.microsoft.php'); |
||
| 58 | $this->loadRoutesFrom(__DIR__.'/../routes/web.microsoft.php'); |
||
| 59 | |||
| 60 | // Trigger generating our swagger oauth security settings based on application env file contents |
||
| 61 | $this->generateSwaggerOauthSecurityScheme(); |
||
| 62 | } |
||
| 63 | |||
| 64 | protected function generateSwaggerOauthSecurityScheme() |
||
| 65 | { |
||
| 66 | // If the routes files for the swagger oauth config is NOT present, and we have all the right info, then generate it really quick |
||
| 67 | $swaggerAzureadFile = __DIR__.'/../routes/swagger.azuread.php'; |
||
| 68 | if (! file_exists($swaggerAzureadFile)) { |
||
| 69 | $aad = new AzureActiveDirectory(env('AZURE_AD_TENANT')); |
||
| 70 | //$authorizationUrl = $aad->authorizationEndpoint . '?resource=https://graph.microsoft.com'; |
||
| 71 | $authorizationUrl = $aad->authorizationEndpoint; |
||
| 72 | $client_id = env('AZURE_AD_CLIENT_ID'); |
||
| 73 | $contents = <<<EOF |
||
| 74 | <?php |
||
| 75 | /** |
||
| 76 | * @SWG\SecurityScheme( |
||
| 77 | * securityDefinition="AzureAD", |
||
| 78 | * type="oauth2", |
||
| 79 | * authorizationUrl="$authorizationUrl", |
||
| 80 | * flow="implicit", |
||
| 81 | * scopes={ |
||
| 82 | * "https://graph.microsoft.com/.default": "Use client_id: $client_id" |
||
| 83 | * } |
||
| 84 | * ) |
||
| 85 | **/ |
||
| 86 | EOF; |
||
| 87 | file_put_contents($swaggerAzureadFile, $contents); |
||
| 92 |
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