| Total Lines | 85 |
| Code Lines | 39 |
| 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 |
||
| 24 | return function (array $paths, string $paths_config_file, bool $is_cli): void { |
||
| 25 | // Le chemin d'accès vers le dossier de l'application |
||
| 26 | if (is_dir($paths['app'])) { |
||
| 27 | if (($_temp = realpath($paths['app'])) !== false) { |
||
| 28 | $paths['app'] = $_temp; |
||
| 29 | } else { |
||
| 30 | $paths['app'] = strtr(rtrim($paths['app'], '/\\'), '/\\', DS . DS); |
||
| 31 | } |
||
| 32 | } else { |
||
| 33 | header('HTTP/1.1 503 Service Unavailable.', true, 503); |
||
| 34 | echo 'Your application folder path does not appear to be set correctly. '; |
||
| 35 | echo 'Please open the following file and correct this: "' . $paths_config_file . '"'; |
||
| 36 | |||
| 37 | exit(3); // EXIT_CONFIG |
||
| 38 | } |
||
| 39 | |||
| 40 | // Le chemin d'accès vers le dossier de stockage des fichiers |
||
| 41 | if (is_dir($paths['storage'])) { |
||
| 42 | if (($_temp = realpath($paths['storage'])) !== false) { |
||
| 43 | $paths['storage'] = $_temp; |
||
| 44 | } else { |
||
| 45 | $paths['storage'] = strtr(rtrim($paths['storage'], '/\\'), '/\\', DS . DS); |
||
| 46 | } |
||
| 47 | } elseif (is_dir($paths['app'] . $paths['storage'] . DS)) { |
||
| 48 | $paths['storage'] = $paths['app'] . strtr(trim($paths['storage'], '/\\'), '/\\', DS . DS); |
||
| 49 | } else { |
||
| 50 | header('HTTP/1.1 503 Service Unavailable.', true, 503); |
||
| 51 | echo 'Your storage folder path does not appear to be set correctly. '; |
||
| 52 | echo 'Please open the following file and correct this: "' . $paths_config_file . '"'; |
||
| 53 | |||
| 54 | exit(3); // EXIT_CONFIG |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Chemin vers le framework |
||
| 59 | */ |
||
| 60 | defined('SYST_PATH') || define('SYST_PATH', dirname(__DIR__) . DS); |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Chemin d'acces du dossier "vendor" |
||
| 64 | */ |
||
| 65 | defined('VENDOR_PATH') || define('VENDOR_PATH', dirname(SYST_PATH, 3) . DS); |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Chemin vers l'application |
||
| 69 | */ |
||
| 70 | defined('APP_PATH') || define('APP_PATH', realpath($paths['app']) . DS); |
||
| 71 | |||
| 72 | /** |
||
| 73 | * Chemin vers le dossier de stockage |
||
| 74 | */ |
||
| 75 | defined('STORAGE_PATH') || define('STORAGE_PATH', realpath($paths['storage']) . DS); |
||
| 76 | |||
| 77 | if (file_exists(APP_PATH . 'Config' . DS . 'constants.php')) { |
||
| 78 | require_once APP_PATH . 'Config' . DS . 'constants.php'; |
||
| 79 | } |
||
| 80 | require_once SYST_PATH . 'Constants' . DS . 'constants.php'; |
||
| 81 | |||
| 82 | /** |
||
| 83 | * On charge le helper `common` qui est utilisé par le framework et presque toutes les applications |
||
| 84 | */ |
||
| 85 | require_once SYST_PATH . 'Helpers' . DS . 'common.php'; |
||
| 86 | |||
| 87 | /** |
||
| 88 | * On initialise le parsing du fichier .env |
||
| 89 | */ |
||
| 90 | DotEnv::init(ROOTPATH); |
||
| 91 | |||
| 92 | // Initialise et enregistre le loader avec la pile SPL autoloader. |
||
| 93 | Services::autoloader()->initialize()->register(); |
||
| 94 | Services::autoloader()->loadHelpers(); |
||
| 95 | |||
| 96 | /** |
||
| 97 | * Initialisation de Kint |
||
| 98 | */ |
||
| 99 | require_once __DIR__ . DS . 'kint.php'; |
||
| 100 | |||
| 101 | /** |
||
| 102 | * Lancement de l'application |
||
| 103 | */ |
||
| 104 | $app = new Application(); |
||
| 105 | $app->init(); |
||
| 106 | |||
| 107 | if (! $is_cli) { |
||
| 108 | $app->run(); |
||
| 109 | } |
||
| 111 |