index.php ➔ _dir()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 37 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * Hummingbird Anime Client
4
 *
5
 * An API client for Hummingbird to manage anime and manga watch lists
6
 *
7
 * PHP version 5.6
8
 *
9
 * @package     HummingbirdAnimeClient
10
 * @author      Timothy J. Warren <[email protected]>
11
 * @copyright   2015 - 2016  Timothy J. Warren
12
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @version     3.1
14
 * @link        https://github.com/timw4mail/HummingBirdAnimeClient
15
 */
16
namespace Aviat\AnimeClient;
17
18
use function Aviat\AnimeClient\loadToml;
19
20
use Aviat\AnimeClient\AnimeClient;
21
use Whoops\Handler\PrettyPageHandler;
22
use Whoops\Run;
23
24
// Work around the silly timezone error
25
$timezone = ini_get('date.timezone');
26
if ($timezone === '' || $timezone === FALSE)
27
{
28
	ini_set('date.timezone', 'GMT');
29
}
30
31
/**
32
 * Joins paths together. Variadic to take an
33
 * arbitrary number of arguments
34
 *
35
 * @return string
36
 */
37
function _dir()
38
{
39
	return implode(DIRECTORY_SEPARATOR, func_get_args());
40
}
41
42
// Define base directories
43
$APP_DIR = _dir(__DIR__, 'app');
44
$APPCONF_DIR = _dir($APP_DIR, 'appConf');
45
$CONF_DIR = _dir($APP_DIR, 'config');
46
47
// Load composer autoloader
48
require _dir(__DIR__, 'vendor/autoload.php');
49
50
// -------------------------------------------------------------------------
51
// Setup error handling
52
// -------------------------------------------------------------------------
53
$whoops = new Run();
54
55
// Set up default handler for general errors
56
$defaultHandler = new PrettyPageHandler();
57
$whoops->pushHandler($defaultHandler);
58
59
// Register as the error handler
60
$whoops->register();
61
62
// -----------------------------------------------------------------------------
63
// Dependency Injection setup
64
// -----------------------------------------------------------------------------
65
require _dir($APPCONF_DIR, 'base_config.php'); // $base_config
66
$di = require _dir($APP_DIR, 'bootstrap.php');
67
68
$config = loadToml($CONF_DIR);
69
$config_array = array_merge($base_config, $config);
70
71
$container = $di($config_array);
72
73
// Unset 'constants'
74
unset($APP_DIR);
75
unset($CONF_DIR);
76
77
// -----------------------------------------------------------------------------
78
// Dispatch to the current route
79
// -----------------------------------------------------------------------------
80
$container->get('dispatcher')->__invoke();