Completed
Pull Request — master (#8)
by Rougin
06:25 queued 02:08
created

InstanceHelper::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
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
            self::$wildfire = new Wildfire($database, $query);
31 3
        }
32 36
    }
33
34
    /**
35
     * Returns the Wildfire instance.
36
     *
37
     * @return \Rougin\Wildfire\Wildfire
38
     */
39 18
    public static function get()
40
    {
41 18
        if (! empty(self::$wildfire)) {
42 18
            return self::$wildfire;
43
        }
44
45
        return null;
46
    }
47
}
48