Completed
Push — master ( 34dc16...e33ec9 )
by Alexander
02:16 queued 10s
created

InitializationTrait::__isInitialized()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Parser Reflection API
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\ParserReflection\Traits;
12
13
14
trait InitializationTrait
15
{
16
    /**
17
     * Is internal reflection is initialized or not
18
     *
19
     * @var boolean
20
     */
21
    private $isInitialized = false;
22
23
    /**
24
     * Initializes internal reflection for calling misc runtime methods
25
     */
26 143
    public function initializeInternalReflection()
27
    {
28 143
        if (!$this->isInitialized) {
29 79
            $this->__initialize();
30 79
            $this->isInitialized = true;
31
        }
32 143
    }
33
34
    /**
35
     * Returns the status of initialization status for internal object
36
     *
37
     * @return bool
38
     */
39 30
    public function __isInitialized()
40
    {
41 30
        return $this->isInitialized;
42
    }
43
44
    /**
45
     * Implementation of internal reflection initialization
46
     *
47
     * @return void
48
     */
49
    abstract protected function __initialize();
50
}
51