FactoryTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __callStatic() 0 6 1
1
<?php
2
3
namespace Helix\DB;
4
5
use Helix\DB;
6
7
/**
8
 * Installs a magic static factory, where the signature can be changed to match the constructor,
9
 * since it's just an annotation.
10
 *
11
 * @method static static factory(DB $db, ...$args)
12
 * @internal
13
 */
14
trait FactoryTrait
15
{
16
17
    /**
18
     * @param string $ignored
19
     * @param array $args The first argument must be a {@link DB} instance.
20
     * @return static
21
     */
22
    public static function __callStatic(string $ignored, array $args)
23
    {
24
        /** @var DB $db */
25
        $db = $args[0];
26
        unset($args[0]);
27
        return $db->factory(static::class, ...$args);
28
    }
29
}
30