1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace RouterOS; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Trait ShortsTrait |
7
|
|
|
* |
8
|
|
|
* All shortcuts was moved to this class |
9
|
|
|
* |
10
|
|
|
* @package RouterOS |
11
|
|
|
* @since 1.0.0 |
12
|
|
|
* @codeCoverageIgnore |
13
|
|
|
*/ |
14
|
|
|
trait ShortsTrait |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Alias for ->query() method |
18
|
|
|
* |
19
|
|
|
* @param array|string|\RouterOS\Interfaces\QueryInterface $endpoint Path of API query or Query object |
20
|
|
|
* @param array|null $where List of where filters |
21
|
|
|
* @param string|null $operations Some operations which need make on response |
22
|
|
|
* @param string|null $tag Mark query with tag |
23
|
|
|
* |
24
|
|
|
* @return \RouterOS\Client |
25
|
|
|
* @since 1.0.0 |
26
|
|
|
*/ |
27
|
|
|
public function q($endpoint, array $where = null, string $operations = null, string $tag = null): Client |
28
|
|
|
{ |
29
|
|
|
return $this->query($endpoint, $where, $operations, $tag); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Alias for ->read() method |
34
|
|
|
* |
35
|
|
|
* @param bool $parse If need parse output to array |
36
|
|
|
* |
37
|
|
|
* @return mixed |
38
|
|
|
* @since 0.7 |
39
|
|
|
*/ |
40
|
|
|
public function r(bool $parse = true) |
41
|
|
|
{ |
42
|
|
|
return $this->read($parse); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Alias for ->readAsIterator() method |
47
|
|
|
* |
48
|
|
|
* @return \RouterOS\ResponseIterator |
49
|
|
|
* @since 1.0.0 |
50
|
|
|
*/ |
51
|
|
|
public function ri(): ResponseIterator |
52
|
|
|
{ |
53
|
|
|
return $this->readAsIterator(); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Alias for ->query()->read() combination of methods |
58
|
|
|
* |
59
|
|
|
* @param array|string|\RouterOS\Interfaces\QueryInterface $endpoint Path of API query or Query object |
60
|
|
|
* @param array|null $where List of where filters |
61
|
|
|
* @param string|null $operations Some operations which need make on response |
62
|
|
|
* @param string|null $tag Mark query with tag |
63
|
|
|
* @param bool $parse If need parse output to array |
64
|
|
|
* |
65
|
|
|
* @return array |
66
|
|
|
* @since 1.0.0 |
67
|
|
|
*/ |
68
|
|
|
public function qr($endpoint, array $where = null, string $operations = null, string $tag = null, bool $parse = true): array |
69
|
|
|
{ |
70
|
|
|
return $this->query($endpoint, $where, $operations, $tag)->read($parse); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* Alias for ->query()->readAsIterator() combination of methods |
75
|
|
|
* |
76
|
|
|
* @param array|string|\RouterOS\Interfaces\QueryInterface $endpoint Path of API query or Query object |
77
|
|
|
* @param array|null $where List of where filters |
78
|
|
|
* @param string|null $operations Some operations which need make on response |
79
|
|
|
* @param string|null $tag Mark query with tag |
80
|
|
|
* |
81
|
|
|
* @return \RouterOS\ResponseIterator |
82
|
|
|
* @since 1.0.0 |
83
|
|
|
*/ |
84
|
|
|
public function qri($endpoint, array $where = null, string $operations = null, string $tag = null): ResponseIterator |
85
|
|
|
{ |
86
|
|
|
return $this->query($endpoint, $where, $operations, $tag)->readAsIterator(); |
|
|
|
|
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|
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
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. 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.