Passed
Push — master ( 9428db...e92e1f )
by y
02:17
created

FactoryTrait::__callStatic()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
nc 1
nop 2
cc 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
 */
13
trait FactoryTrait {
14
15
    /**
16
     * @param string $ignored
17
     * @param array $args The first argument must be a {@link DB} instance.
18
     * @return static
19
     */
20
    public static function __callStatic (string $ignored, array $args) {
21
        /** @var DB $db */
22
        $db = $args[0];
23
        unset($args[0]);
24
        return $db->factory(static::class, ...$args);
25
    }
26
}