Completed
Push — master ( 45c272...07cbe0 )
by Mr
13s queued 10s
created

src/ShortsTrait.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
     * @param array $options
37
     *
38
     * @return mixed
39
     * @since 0.7
40
     */
41
    public function r(bool $parse = true, array $options = [])
42
    {
43
        return $this->read($parse, $options);
0 ignored issues
show
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...
44
    }
45
46
    /**
47
     * Alias for ->readAsIterator() method
48
     *
49
     * @return \RouterOS\ResponseIterator
50
     * @since 1.0.0
51
     */
52
    public function ri(): ResponseIterator
53
    {
54
        return $this->readAsIterator();
0 ignored issues
show
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...
55
    }
56
57
    /**
58
     * Alias for ->query()->read() combination of methods
59
     *
60
     * @param array|string|\RouterOS\Interfaces\QueryInterface $endpoint   Path of API query or Query object
61
     * @param array|null                                       $where      List of where filters
62
     * @param string|null                                      $operations Some operations which need make on response
63
     * @param string|null                                      $tag        Mark query with tag
64
     * @param bool                                             $parse      If need parse output to array
65
     *
66
     * @return array
67
     * @since 1.0.0
68
     */
69
    public function qr($endpoint, array $where = null, string $operations = null, string $tag = null, bool $parse = true): array
70
    {
71
        return $this->query($endpoint, $where, $operations, $tag)->read($parse);
0 ignored issues
show
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...
72
    }
73
74
    /**
75
     * Alias for ->query()->readAsIterator() combination of methods
76
     *
77
     * @param array|string|\RouterOS\Interfaces\QueryInterface $endpoint   Path of API query or Query object
78
     * @param array|null                                       $where      List of where filters
79
     * @param string|null                                      $operations Some operations which need make on response
80
     * @param string|null                                      $tag        Mark query with tag
81
     *
82
     * @return \RouterOS\ResponseIterator
83
     * @since 1.0.0
84
     */
85
    public function qri($endpoint, array $where = null, string $operations = null, string $tag = null): ResponseIterator
86
    {
87
        return $this->query($endpoint, $where, $operations, $tag)->readAsIterator();
0 ignored issues
show
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...
88
    }
89
}
90