FactoryFormatTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A fromFormat() 0 3 1
1
<?php
2
3
namespace Helix\DB\Fluent;
4
5
use Helix\DB;
6
use Helix\DB\FactoryTrait;
7
8
/**
9
 * Create an expression using driver-appropriate SQL.
10
 *
11
 * @internal
12
 */
13
trait FactoryFormatTrait
14
{
15
16
    use FactoryTrait;
17
18
    /**
19
     * Creates an expression using driver-appropriate SQL.
20
     *
21
     * @param DB $db
22
     * @param string[] $formats Formats for `sprintf()`, keyed by driver.
23
     * @param ...$args
24
     * @return static
25
     */
26
    public static function fromFormat(DB $db, array $formats, ...$args)
27
    {
28
        return static::factory($db, sprintf($formats[$db->getDriver()], ...$args));
29
    }
30
31
}
32