FactoryTrait::__callStatic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
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