Completed
Push — master ( 674f63...1322e1 )
by Nazar
04:59
created

Query::query()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package   CleverStyle Framework
4
 * @author    Nazar Mokrynskyi <[email protected]>
5
 * @copyright Copyright (c) 2016, Nazar Mokrynskyi
6
 * @license   MIT License, see license.txt
7
 */
8
namespace cs\Request;
9
10
trait Query {
11
	/**
12
	 * Query array, similar to `$_GET`
13
	 *
14
	 * @var array
15
	 */
16
	public $query;
17
	/**
18
	 * @param array $query Typically `$_GET`
19
	 */
20 28
	public function init_query ($query = []) {
21 28
		$this->query = $query;
22 28
	}
23
	/**
24
	 * Get query parameter by name
25
	 *
26
	 * @param string[]|string[][] $name
27
	 *
28
	 * @return mixed|mixed[]|null Query parameter (or associative array of Query parameters) if exists or `null` otherwise (in case if `$name` is an array
29
	 *                             even one missing key will cause the whole thing to fail)
30
	 */
31 2
	public function query (...$name) {
32 2
		return $this->get_property_items('query', $name);
1 ignored issue
show
Bug introduced by
It seems like get_property_items() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
33
	}
34
}
35