Passed
Push — 5.0 ( 525776...c16c04 )
by Marc André
04:03 queued 01:58
created

Core::getContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the Cervo package.
5
 *
6
 * Copyright (c) 2010-2018 Nevraxe inc. & Marc André Audet <[email protected]>.
7
 *
8
 * @package   Cervo
9
 * @author    Marc André Audet <[email protected]>
10
 * @copyright 2010 - 2018 Nevraxe inc. & Marc André Audet
11
 * @license   See LICENSE.md  BSD-2-Clauses
12
 * @link      https://github.com/Nevraxe/Cervo
13
 * @since     5.0.0
14
 */
15
16
declare(strict_types=1);
17
18
namespace Cervo;
19
20
use Cervo\Config\BaseConfig;
21
use Cervo\Exceptions\ControllerReflection\AlreadyInitialisedException;
22
23
24
/**
25
 * Core class for Cervo.
26
 *
27
 * @author Marc André Audet <[email protected]>
28
 */
29
final class Core
30
{
31
    private static $isInit = false;
32
    private static $context = null;
33
34
    public static function init(?BaseConfig $config = null)
35
    {
36
        if (self::$isInit === true) {
37
            throw new AlreadyInitialisedException;
38
        }
39
40
        self::$isInit = true;
41
        self::$context = new Context($config);
42
    }
43
44
    public static function getContext()
45
    {
46
        return self::$context;
47
    }
48
}
49