Completed
Push — master ( c09486...c4a020 )
by Mr
03:43
created

ShortsTrait::q()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 2
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
 */
13
trait ShortsTrait
14
{
15
    /**
16
     * Alias for ->write() method
17
     *
18
     * @param string|array|\RouterOS\Query $query
19
     * @return \RouterOS\Client
20
     * @throws \RouterOS\Exceptions\QueryException
21
     */
22 1
    public function w($query): Client
23
    {
24 1
        return $this->write($query);
0 ignored issues
show
Bug introduced by
It seems like write() 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...
25
    }
26
27
    /**
28
     * Alias for ->query() method
29
     *
30
     * @param string      $endpoint   Path of API query
31
     * @param array|null  $where      List of where filters
32
     * @param string|null $operations Some operations which need make on response
33
     * @param string|null $tag        Mark query with tag
34
     * @return \RouterOS\Client
35
     * @throws \RouterOS\Exceptions\QueryException
36
     * @since 1.0.0
37
     */
38
    public function q(string $endpoint, array $where = null, string $operations = null, string $tag = null): Client
39
    {
40
        return $this->query($endpoint, $where, $operations, $tag);
0 ignored issues
show
Bug introduced by
It seems like query() 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...
41
    }
42
43
    /**
44
     * Alias for ->read() method
45
     *
46
     * @param bool $parse
47
     * @return mixed
48
     * @since 0.7
49
     */
50 1
    public function r(bool $parse = true)
51
    {
52 1
        return $this->read($parse);
0 ignored issues
show
Bug introduced by
It seems like read() 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...
53
    }
54
55
    /**
56
     * Alias for ->readAsIterator() method
57
     *
58
     * @return \RouterOS\ResponseIterator
59
     * @since 1.0.0
60
     */
61
    public function ri(): ResponseIterator
62
    {
63
        return $this->readAsIterator();
0 ignored issues
show
Bug introduced by
It seems like readAsIterator() 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...
64
    }
65
66
    /**
67
     * Alias for ->write()->read() combination of methods
68
     *
69
     * @param string|array|\RouterOS\Query $query
70
     * @param bool                         $parse
71
     * @return array
72
     * @throws \RouterOS\Exceptions\ClientException
73
     * @throws \RouterOS\Exceptions\QueryException
74
     * @since 0.6
75
     */
76 4
    public function wr($query, bool $parse = true): array
77
    {
78 4
        return $this->write($query)->read($parse);
0 ignored issues
show
Bug introduced by
It seems like write() 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...
79
    }
80
81
    /**
82
     * Alias for ->write()->read() combination of methods
83
     *
84
     * @param string      $endpoint   Path of API query
85
     * @param array|null  $where      List of where filters
86
     * @param string|null $operations Some operations which need make on response
87
     * @param string|null $tag        Mark query with tag
88
     * @param bool        $parse
89
     * @return \RouterOS\Client
90
     * @throws \RouterOS\Exceptions\QueryException
91
     * @since 1.0.0
92
     */
93
    public function qr(string $endpoint, array $where = null, string $operations = null, string $tag = null, bool $parse = true): array
94
    {
95
        return $this->query($endpoint, $where, $operations, $tag)->read($parse);
0 ignored issues
show
Bug introduced by
It seems like query() 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...
96
    }
97
98
    /**
99
     * Alias for ->write()->readAsIterator() combination of methods
100
     *
101
     * @param string|array|\RouterOS\Query $query
102
     * @return \RouterOS\ResponseIterator
103
     * @throws \RouterOS\Exceptions\ClientException
104
     * @throws \RouterOS\Exceptions\QueryException
105
     * @since 1.0.0
106
     */
107
    public function wri($query): ResponseIterator
108
    {
109
        return $this->write($query)->readAsIterator();
0 ignored issues
show
Bug introduced by
It seems like write() 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...
110
    }
111
112
    /**
113
     * Alias for ->write()->read() combination of methods
114
     *
115
     * @param string      $endpoint   Path of API query
116
     * @param array|null  $where      List of where filters
117
     * @param string|null $operations Some operations which need make on response
118
     * @param string|null $tag        Mark query with tag
119
     * @return \RouterOS\ResponseIterator
120
     * @throws \RouterOS\Exceptions\QueryException
121
     * @since 1.0.0
122
     */
123
    public function qri(string $endpoint, array $where = null, string $operations = null, string $tag = null): ResponseIterator
124
    {
125
        return $this->query($endpoint, $where, $operations, $tag)->readAsIterator();
0 ignored issues
show
Bug introduced by
It seems like query() 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...
126
    }
127
}
128