Completed
Push — master ( ed61e9...497a60 )
by Rougin
04:46
created

InstanceHelper::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Rougin\Wildfire\Helpers;
4
5
use Rougin\Wildfire\Wildfire;
6
7
/**
8
 * Instance Helper
9
 *
10
 * @package Wildfire
11
 * @author  Rougin Royce Gutib <[email protected]>
12
 */
13
class InstanceHelper
14
{
15
    /**
16
     * @var \Rougin\Wildfire\Wildfire
17
     */
18
    protected static $wildfire;
19
20
    /**
21
     * Factory method to create Wildfire instance.
22
     *
23
     * @param  \CI_DB_query_builder|null $database
24
     * @param  \CI_DB_result|null        $query
25
     * @return void
26
     */
27 36
    public static function create($database = null, $query = null)
28
    {
29 36
        if (empty(self::$wildfire)) {
30 3
            $wildfire = new Wildfire($database, $query);
31
32 3
            self::$wildfire = $wildfire;
33 3
        }
34 36
    }
35
36
    /**
37
     * Returns the Wildfire instance.
38
     *
39
     * @return \Rougin\Wildfire\Wildfire
40
     */
41 21
    public static function get()
42
    {
43 21
        return empty(self::$wildfire) ? null : self::$wildfire;
44
    }
45
}
46