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

Mysql   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 37
rs 10
wmc 3
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 9 2
A defineGlobals() 0 4 1
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