Completed
Push — master ( ee6d65...c2027d )
by Woody
03:25
created

ValueList::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Latitude\QueryBuilder;
5
6
use Countable;
7
use Iterator;
8
9
class ValueList implements
10
    Countable,
11
    Statement
12
{
13
    use Traits\CanConvertIteratorToString;
14
    use Traits\CanReplaceBooleanAndNullValues;
15
16
    /**
17
     * Create a new value list.
18
     */
19 12
    public static function make(...$params)
20
    {
21 12
        $values = new static($params);
0 ignored issues
show
Unused Code introduced by Woody Gilk
The call to ValueList::__construct() has too many arguments starting with $params.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
22 12
        $values->params = $params;
23 12
        return $values;
24
    }
25
26
    // Countable
27 1
    public function count()
28
    {
29 1
        return \count($this->params);
30
    }
31
32
    // Statement
33 12
    public function sql(Identifier $identifier = null): string
34
    {
35 12
        return $this->stringifyIterator($this->generatePlaceholders());
36
    }
37
38
    // Statement
39 12
    public function params(): array
40
    {
41 12
        return $this->placeholderParams();
42
    }
43
44
    /**
45
     * @var array
46
     */
47
    protected $params;
48
49
    /**
50
     * Generate a placeholder.
51
     */
52 12
    protected function generatePlaceholders(): Iterator
53
    {
54 12
        foreach (\array_keys($this->params) as $index) {
55 12
            yield $this->placeholderValue($index);
56
        }
57 12
    }
58
}
59