| Conditions | 12 |
| Paths | 97 |
| Total Lines | 52 |
| Code Lines | 31 |
| 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 |
||
| 35 | function getAppInstance() { |
||
|
|
|||
| 36 | $subfolder = ''; |
||
| 37 | // Check to see if the configuration file exists, if not, explain |
||
| 38 | if (!\file_exists(\dirname(__DIR__) . '/config.inc.php')) { |
||
| 39 | die('Configuration error: Copy config.inc.php-dist to config.inc.php and edit appropriately.'); |
||
| 40 | } |
||
| 41 | $conf = []; |
||
| 42 | |||
| 43 | include_once \dirname(__DIR__) . '/config.inc.php'; |
||
| 44 | |||
| 45 | if (isset($conf['subfolder']) && \is_string($conf['subfolder'])) { |
||
| 46 | $subfolder = $conf['subfolder']; |
||
| 47 | } elseif (\PHP_SAPI === 'cli-server') { |
||
| 48 | $subfolder = '/index.php'; |
||
| 49 | } elseif (isset($_SERVER['DOCUMENT_ROOT'])) { |
||
| 50 | $subfolder = \str_replace( |
||
| 51 | $_SERVER['DOCUMENT_ROOT'], |
||
| 52 | '', |
||
| 53 | \dirname(__DIR__) |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | $conf['subfolder'] = $subfolder; |
||
| 58 | |||
| 59 | |||
| 60 | $conf['debugmode'] = (!isset($conf['debugmode'])) ? false : (bool) ($conf['debugmode']); |
||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | if ($conf['debugmode']) { |
||
| 65 | \ini_set('display_errors', 'On'); |
||
| 66 | |||
| 67 | \ini_set('display_startup_errors', 'On'); |
||
| 68 | \ini_set('opcache.revalidate_freq', '0'); |
||
| 69 | \error_reporting(\E_ALL); |
||
| 70 | |||
| 71 | if (\array_key_exists('register_debuggers', $conf) && \is_callable($conf['register_debuggers'])) { |
||
| 72 | $conf['register_debuggers'](); |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | |||
| 77 | $conf['BASE_PATH'] = BASE_PATH; |
||
| 78 | $conf['theme_path'] = BASE_PATH . '/assets/themes'; |
||
| 79 | \defined('IN_TEST') || \define('IN_TEST', false); |
||
| 80 | $conf['IN_TEST'] = IN_TEST; |
||
| 81 | \ini_set('display_errors', strval($conf['debugmode'])); |
||
| 82 | \defined('ADODB_ASSOC_CASE') || \define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE); |
||
| 83 | |||
| 84 | // Fetch App and DI Container |
||
| 85 | $app = \PHPPgAdmin\ContainerUtils::getAppInstance($conf); |
||
| 86 | return $app; |
||
| 87 | }; |
||
| 157 |