Completed
Push — master ( 87995b...abed83 )
by Mr
03:29
created

ShortsTrait::r()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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 ->write()->read() combination of methods
43
     *
44
     * @param string|array|\RouterOS\Query $query
45
     * @param bool                         $parse
46
     * @return array
47
     * @throws \RouterOS\Exceptions\ClientException
48
     * @throws \RouterOS\Exceptions\QueryException
49
     * @since 0.6
50
     */
51 4
    public function wr($query, bool $parse = true): array
52
    {
53 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...
54
    }
55
}
56