Passed
Push — master ( 166838...df99f5 )
by Bruno
06:43 queued 17s
created

NamespaceTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 2
b 0
f 0
dl 0
loc 38
ccs 0
cts 3
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerFactory() 0 3 1
A appendNamespace() 0 3 1
A getNamespaces() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Formularium\Factory;
4
5
trait NamespaceTrait
6
{
7
    /**
8
     * Namespaces to search
9
     *
10
     * @var string[]
11
     */
12
    protected static $namespaces = [];
13
14
    /**
15
     * External factory functions.
16
     *
17
     * @var callable[]
18
     */
19
    protected static $factories = [];
20
21
    public static function registerFactory(callable $factory): void
22
    {
23
        static::$factories[] = $factory;
24
    }
25
26
    /**
27
     * @param string $ns The namespace to add
28
     * @return void
29
     * @codeCoverageIgnore
30
     */
31
    public static function appendNamespace(string $ns): void
32
    {
33
        static::$namespaces[] = $ns;
34
    }
35
36
    /**
37
     * @return string[]
38
     * @codeCoverageIgnore
39
     */
40
    public static function getNamespaces(): array
41
    {
42
        return static::$namespaces;
43
    }
44
}
45