| Conditions | 3 |
| Paths | 4 |
| Total Lines | 52 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 15 | public static function init(string $env = 'production') |
||
| 16 | { |
||
| 17 | // check response performance |
||
| 18 | $GLOBALS['KONTIKI_START_TIME'] = microtime(true); |
||
| 19 | |||
| 20 | // Set the error log handler |
||
| 21 | Log::getInstance()->registerHandlers(); |
||
| 22 | |||
| 23 | // load config |
||
| 24 | $projectPath = $env == 'development' ? dirname(__DIR__) : dirname(__DIR__, 4); |
||
| 25 | $dotenv = Dotenv::createImmutable($projectPath . "/config/{$env}/"); |
||
| 26 | $dotenv->load(); |
||
| 27 | |||
| 28 | // Load Functions |
||
| 29 | require __DIR__ . '/functions/functions.php'; |
||
| 30 | |||
| 31 | // setenv |
||
| 32 | setenv('ENV', $env); |
||
| 33 | setenv('PROJECT_PATH', $projectPath); |
||
| 34 | |||
| 35 | // Load default language on class load |
||
| 36 | $language = env('APPLANG', 'en'); |
||
| 37 | Utils\Lang::setLanguage($language); |
||
| 38 | |||
| 39 | // Configure a PHP-DI container |
||
| 40 | $container = new Container(); |
||
| 41 | AppFactory::setContainer($container); |
||
| 42 | |||
| 43 | // Create a Slim application |
||
| 44 | $app = AppFactory::create(); |
||
| 45 | $app->addErrorMiddleware(true, true, true); |
||
| 46 | $basePath = env('BASEPATH', '/'); |
||
| 47 | $app->setBasePath($basePath); |
||
| 48 | |||
| 49 | // Add auth check |
||
| 50 | $app->add(AuthMiddleware::class); |
||
| 51 | |||
| 52 | // Add headers for security measures |
||
| 53 | $app->add(SecurityHeadersMiddleware::class); |
||
| 54 | |||
| 55 | // Set dependencies |
||
| 56 | $dependencies = new Config\Dependencies($app); |
||
| 57 | $dependencies->register(); |
||
| 58 | |||
| 59 | // Set Route |
||
| 60 | $auth = $app->getContainer()->get(Core\Auth::class); |
||
| 61 | $routesClass = class_exists('App\Config\Routes') |
||
| 62 | ? new \App\Config\Routes() |
||
|
|
|||
| 63 | : new \Jidaikobo\Kontiki\Config\Routes(); |
||
| 64 | $routesClass->register($app, $container, $auth); |
||
| 65 | |||
| 66 | return $app; |
||
| 67 | } |
||
| 84 |
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