WhereLikeProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 42
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A like() 0 4 1
A notLike() 0 4 1
A orLike() 0 4 1
A orNotLike() 0 4 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 WhereLikeProvider
20
{
21
    /**
22
     * @param string $field
23
     * @param string|mixed $value
24
     * @return Query|$this
25
     */
26 2
    public function like(string $field, $value): self
27
    {
28 2
        return $this->where($field, Operator::LIKE, $value);
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...
29
    }
30
31
    /**
32
     * @param string $field
33
     * @param string|mixed $value
34
     * @return Query|$this
35
     */
36 2
    public function notLike(string $field, $value): self
37
    {
38 2
        return $this->where($field, Operator::NOT_LIKE, $value);
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...
39
    }
40
41
    /**
42
     * @param string $field
43
     * @param string|mixed $value
44
     * @return Query|$this
45
     */
46 1
    public function orLike(string $field, $value): self
47
    {
48 1
        return $this->or()->where($field, Operator::LIKE, $value);
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...
49
    }
50
51
    /**
52
     * @param string $field
53
     * @param string|mixed $value
54
     * @return Query|$this
55
     */
56 1
    public function orNotLike(string $field, $value): self
57
    {
58 1
        return $this->or()->where($field, Operator::NOT_LIKE, $value);
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...
59
    }
60
}
61