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

NameMatchQuery::matchQuery()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace League\Plates\Template\Query\MatchQuery;
4
5
use League\Plates\Template;
6
use League\Plates\Template\Query\MatchQuery;
7
8
class NameMatchQuery implements MatchQuery
9
{
10
    public function matchQuery($query, Template $template) {
11
        return $query === $template->name
12
            || $query === '*'
13
            || $this->matchesWildcardPrefix($query, $template);
14
    }
15
16
    private function matchesWildcardPrefix($query, Template $template) {
17
        return strlen($query)
18
            && $query[strlen($query) - 1] === '*'
19
            && strpos($template->name, substr($query, 0, -1)) === 0;
20
    }
21
}
22