Completed
Push — master ( 008f74...6d49ec )
by Matteo
9s
created

Mysql::defineGlobals()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Mattbit\MysqlCompat;
4
5
/**
6
 * Class Mysql
7
 * Provides a facade to access the Mysql functions using a Manager singleton.
8
 */
9
class Mysql
10
{
11
    /**
12
     * The database manager service.
13
     *
14
     * @var Bridge
15
     */
16
    private static $bridge;
17
18
    /**
19
     * Forward static calls to the manager singleton.
20
     *
21
     * @param  $method
22
     * @param  $args
23
     *
24
     * @return mixed
25
     */
26
    public static function __callStatic($method, $args)
27
    {
28
        if (self::$bridge === null) {
29
            $manager = new Manager(new ConnectionFactory());
30
            self::$bridge = new Bridge($manager);
31
        }
32
33
        return call_user_func_array([self::$bridge, $method], $args);
34
    }
35
36
    /**
37
     * Defines the old global functions and constants.
38
     *
39
     * @return void
40
     */
41
    public static function defineGlobals()
42
    {
43
        require_once __DIR__ . '/globals.php';
44
    }
45
}
46