WhereBetweenProvider::whereBetween()   A
last analyzed

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 3
crap 1
1
<?php
2
/**
3
 * This file is part of Hydrogen package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace RDS\Hydrogen\Query\WhereProvider;
11
12
use RDS\Hydrogen\Criteria\Where\Operator;
13
use RDS\Hydrogen\Query;
14
15
/**
16
 * Trait WhereBetweenProvider
17
 * @mixin Query\WhereProvider
18
 */
19
trait WhereBetweenProvider
20
{
21
    /**
22
     * @param string $field
23
     * @param mixed $from
24
     * @param mixed $to
25
     * @return Query|$this|self
26
     */
27 1
    public function orWhereBetween(string $field, $from, $to): self
28
    {
29 1
        return $this->or()->whereBetween($field, $from, $to);
0 ignored issues
show
Bug introduced by
It seems like or() 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
     * @param string $field
34
     * @param mixed $from
35
     * @param mixed $to
36
     * @return Query|$this|self
37
     */
38 2
    public function whereBetween(string $field, $from, $to): self
39
    {
40 2
        return $this->where($field, Operator::BTW, [$from, $to]);
0 ignored issues
show
Bug introduced by
It seems like where() 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
     * @param string $field
45
     * @param mixed $from
46
     * @param mixed $to
47
     * @return Query|$this|self
48
     */
49 1
    public function orWhereNotBetween(string $field, $from, $to): self
50
    {
51 1
        return $this->or()->whereNotBetween($field, $from, $to);
0 ignored issues
show
Bug introduced by
It seems like or() 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...
52
    }
53
54
    /**
55
     * @param string $field
56
     * @param mixed $from
57
     * @param mixed $to
58
     * @return Query|$this|self
59
     */
60 2
    public function whereNotBetween(string $field, $from, $to): self
61
    {
62 2
        return $this->where($field, Operator::NOT_BTW, [$from, $to]);
0 ignored issues
show
Bug introduced by
It seems like where() 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...
63
    }
64
}
65