Control   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 30
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A deregister() 0 3 1
A retrieving() 0 4 1
A register() 0 3 1
1
<?php
2
/**
3
 * Shaper's control
4
 * User: moyo
5
 * Date: 22/02/2018
6
 * Time: 3:24 PM
7
 */
8
9
namespace Carno\Shaping;
10
11
use Closure;
12
13
class Control
14
{
15
    /**
16
     * @var Shaper[]
17
     */
18
    private static $instances = [];
19
20
    /**
21
     * @param Shaper $shaper
22
     */
23
    public static function register(Shaper $shaper) : void
24
    {
25
        self::$instances[spl_object_id($shaper)] = $shaper;
26
    }
27
28
    /**
29
     * @param Shaper $shaper
30
     */
31
    public static function deregister(Shaper $shaper) : void
32
    {
33
        unset(self::$instances[spl_object_id($shaper)]);
34
    }
35
36
    /**
37
     * @param Closure $receiver
38
     */
39
    public static function retrieving(Closure $receiver) : void
40
    {
41
        array_walk(self::$instances, function (Shaper $shaper) use ($receiver) {
42
            $receiver($shaper);
43
        });
44
    }
45
}
46