Completed
Push — master ( 6387a2...3f53e4 )
by Sercan
02:30
created

Exchange::getFactory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace CryptoMarkets;
4
5
use CryptoMarkets\Common\GatewayFactory;
6
7
class Exchange
8
{
9
    /**
10
     * The gateway factory instance.
11
     *
12
     * @var GatewayFactory
13
     */
14
    private static $factory;
15
16
    /**
17
     * Get the gateway factory instance.
18
     *
19
     * @return GatewayFactory
20
     */
21
    public static function getFactory()
22
    {
23
        if (is_null(self::$factory)) {
24
            self::$factory = new GatewayFactory;
25
        }
26
27
        return self::$factory;
28
    }
29
30
    /**
31
     * Set the gateway factory instance.
32
     *
33
     * @param  GatewayFactory
34
     * @return void
35
     */
36
    public static function setFactory(GatewayFactory $factory = null)
37
    {
38
        self::$factory = $factory;
39
    }
40
41
    /**
42
     * Handle dynamic static method calls into the method.
43
     *
44
     * @param  string  $method
45
     * @param  array  $parameters
46
     * @return mixed
47
     */
48
    public static function __callStatic($method, $parameters)
49
    {
50
        return (self::getFactory())->$method(...$parameters);
51
    }
52
}
53