ConfigEventManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addListener() 0 3 1
A onChange() 0 5 2
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\App\Config;
4
5
/**
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
6
 * ConfigEventManager.php
7
 *
8
 * Call listeners on config changes.
9
 *
10
 * @package jaxon-core
11
 * @author Thierry Feuzeu <[email protected]>
12
 * @copyright 2022 Thierry Feuzeu <[email protected]>
13
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
14
 * @link https://github.com/jaxon-php/jaxon-core
15
 */
16
17
use Jaxon\Di\Container;
18
use Jaxon\Utils\Config\Config;
19
20
class ConfigEventManager implements ConfigListenerInterface
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ConfigEventManager
Loading history...
21
{
22
    /**
23
     * @var Container
24
     */
25
    protected $di;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
26
27
    /**
28
     * @var string[]
29
     */
30
    protected $aListeners = [];
31
32
    /**
33
     * The constructor
34
     *
35
     * @param Container $di
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     */
37
    public function __construct(Container $di)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
38
    {
39
        $this->di = $di;
40
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
41
42
    /**
43
     * Add a listener
44
     *
45
     * @param string $sClassName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
46
     *
47
     * @return void
48
     */
49
    public function addListener(string $sClassName)
50
    {
51
        $this->aListeners[] = $sClassName;
52
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
53
54
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $xConfig should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $sName should have a doc-comment as per coding-style.
Loading history...
55
     * @inheritDoc
56
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
57
    public function onChange(Config $xConfig, string $sName)
58
    {
59
        foreach($this->aListeners as $sListener)
60
        {
61
            $this->di->g($sListener)->onChange($xConfig, $sName);
62
        }
63
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
64
}
65