Completed
Push — 186-data ( d4ee1e )
by
unknown
08:25 queued 10s
created

QueryStore::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Template\Query;
4
5
use League\Plates;
6
7
/** Stores template queries with data associated with the given query */
8
final class QueryStore
9
{
10
    private $match_query;
11
    private $items;
12
13
    public function __construct(MatchQuery $match_query) {
14
        $this->match_query = $match_query;
15
        $this->items = [];
16
    }
17
18
    public function add($query, $data) {
19
        $this->items[] = [$query, $data];
20
    }
21
22
    /** return all of the queries + data tuples that match the given template */
23
    public function resolve(Plates\Template $template) {
24
        $items = array_filter($this->items, function($tup) use ($template) {
25
            list($query, $data) = $tup;
0 ignored issues
show
Unused Code introduced by
The assignment to $data is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
26
            return $this->match_query->matchQuery($query, $template);
27
        });
28
        return array_map($items, function($tup) { return $tup[1]; });
29
    }
30
}
31