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

QueryStore   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 3 1
A resolve() 0 7 1
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