Passed
Push — master ( c79316...ecb90a )
by Bruno
07:34
created

NamespaceTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerFactory() 0 3 1
A appendNamespace() 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