ExtensionAbstract   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 50
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A methodsAvailable() 0 4 1
A boot() 0 13 2
bootExtension() 0 1 ?
1
<?php
2
/**
3
 * Phossa Project
4
 *
5
 * PHP version 5.4
6
 *
7
 * @category  Library
8
 * @package   Phossa2\Shared
9
 * @copyright Copyright (c) 2016 phossa.com
10
 * @license   http://mit-license.org/ MIT License
11
 * @link      http://www.phossa.com/
12
 */
13
/*# declare(strict_types=1); */
14
15
namespace Phossa2\Shared\Extension;
16
17
use Phossa2\Shared\Base\ObjectAbstract;
18
19
/**
20
 * ExtensionAbstract
21
 *
22
 * @package Phossa2\Shared
23
 * @author  Hong Zhang <[email protected]>
24
 * @see     ObjectAbstract
25
 * @see     ExtensionInterface
26
 * @version 2.0.23
27
 * @since   2.0.23 added
28
 */
29
abstract class ExtensionAbstract extends ObjectAbstract implements ExtensionInterface
30
{
31
    /**
32
     * The server object
33
     *
34
     * @var    ExtensionAwareInterface
35
     * @access protected
36
     */
37
    protected $server;
38
39
    /**
40
     * The lazy boot flag
41
     *
42
     * @var    bool
43
     * @access protected
44
     */
45
    protected $booted = false;
46
47
    /**
48
     * {@inheritDoc}
49
     */
50
    public function methodsAvailable()/*# : array */
51
    {
52
        return [];
53
    }
54
55
    /**
56
     * {@inheritDoc}
57
     */
58
    public function boot(ExtensionAwareInterface $server)
59
    {
60
        if (!$this->booted) {
61
            // bind server
62
            $this->server = $server;
63
64
            // call user defined boot
65
            $this->bootExtension();
66
67
            // call your own bootMethod here
68
            $this->booted = true;
69
        }
70
    }
71
72
    /**
73
     * The real boot method
74
     *
75
     * @access protected
76
     */
77
    abstract protected function bootExtension();
78
}
79