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

InstanceHelper::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 1
b 0
f 0
cc 2
eloc 3
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
            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