Completed
Push — master ( f7dc06...b96cfb )
by Mr
03:59
created

ShortsTrait::ri()   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 0
crap 2
1
<?php
2
3
namespace RouterOS;
4
5
use RouterOS\Interfaces\ClientInterface;
6
7
/**
8
 * Trait ShortsTrait
9
 *
10
 * All shortcuts was moved to this class
11
 *
12
 * @package RouterOS
13
 * @since 0.10
14
 */
15
trait ShortsTrait
16
{
17
    /**
18
     * Alias for ->write() method
19
     *
20
     * @param string|array|\RouterOS\Query $query
21
     * @return \RouterOS\Interfaces\ClientInterface
22
     * @throws \RouterOS\Exceptions\QueryException
23
     */
24 1
    public function w($query): ClientInterface
25
    {
26 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...
27
    }
28
29
    /**
30
     * Alias for ->read() method
31
     *
32
     * @param bool $parse
33
     * @return mixed
34
     * @since 0.7
35
     */
36 1
    public function r(bool $parse = true)
37
    {
38 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...
39
    }
40
41
    /**
42
     * Alias for ->readAsIterator() method
43
     *
44
     * @return mixed
45
     * @since 0.7
46
     */
47
    public function ri()
48
    {
49
        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...
50
    }
51
52
    /**
53
     * Alias for ->write()->read() combination of methods
54
     *
55
     * @param string|array|\RouterOS\Query $query
56
     * @param bool                         $parse
57
     * @return array
58
     * @throws \RouterOS\Exceptions\ClientException
59
     * @throws \RouterOS\Exceptions\QueryException
60
     * @since 0.6
61
     */
62 4
    public function wr($query, bool $parse = true): array
63
    {
64 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...
65
    }
66
67
    /**
68
     * Alias for ->write()->read() combination of methods
69
     *
70
     * @param string|array|\RouterOS\Query $query
71
     * @return array
72
     * @throws \RouterOS\Exceptions\ClientException
73
     * @throws \RouterOS\Exceptions\QueryException
74
     * @since 0.6
75
     */
76
    public function wri($query): array
77
    {
78
        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...
79
    }
80
}
81