Completed
Pull Request — master (#40)
by Mr
06:35
created

ShortsTrait::w()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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);
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...
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);
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...
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();
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...
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);
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...
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();
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...
87
    }
88
}
89