Completed
Branch develop (205409)
by Timothy
07:06
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 35 and the first side effect is on line 23.

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 Aviat\AnimeClient\AnimeClient;
19
use Whoops\Handler\PrettyPageHandler;
20
use Whoops\Run;
21
22
// Work around the silly timezone error
23
$timezone = ini_get('date.timezone');
24
if ($timezone === '' || $timezone === FALSE)
25
{
26
	ini_set('date.timezone', 'GMT');
27
}
28
29
/**
30
 * Joins paths together. Variadic to take an
31
 * arbitrary number of arguments
32
 *
33
 * @return string
34
 */
35
function _dir()
36
{
37
	return implode(DIRECTORY_SEPARATOR, func_get_args());
38
}
39
40
// Define base directories
41
$APP_DIR = _dir(__DIR__, 'app');
42
$CONF_DIR = _dir($APP_DIR, 'config');
43
44
// Load composer autoloader
45
require _dir(__DIR__, '/vendor/autoload.php');
46
47
// -------------------------------------------------------------------------
48
// Setup error handling
49
// -------------------------------------------------------------------------
50
$whoops = new Run();
51
52
// Set up default handler for general errors
53
$defaultHandler = new PrettyPageHandler();
54
$whoops->pushHandler($defaultHandler);
55
56
// Register as the error handler
57
if (array_key_exists('whoops', $_GET))
58
{
59
	$whoops->register();
60
}
61
62
// -----------------------------------------------------------------------------
63
// Dependency Injection setup
64
// -----------------------------------------------------------------------------
65
require _dir($CONF_DIR, 'base_config.php'); // $base_config
66
$di = require _dir($APP_DIR, 'bootstrap.php');
67
68
$config = AnimeClient::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();
81
82
// End of index.php