AddressBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 4
Bugs 2 Features 0
Metric Value
wmc 2
eloc 10
c 4
b 2
f 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A whereAddressLike() 0 11 1
A whereType() 0 5 1
1
<?php
2
3
namespace Sfneal\Address\Builders;
4
5
use Sfneal\Builders\QueryBuilder;
6
7
class AddressBuilder extends QueryBuilder
8
{
9
    /**
10
     * Scope query results to Address's associated with a particular model.
11
     *
12
     * @param  string  $addressableType
13
     * @param  string  $operator
14
     * @param  string  $boolean
15
     * @return $this
16
     */
17
    public function whereType(string $addressableType, string $operator = '=', string $boolean = 'and'): self
18
    {
19
        $this->where('addressable_type', $operator, $addressableType, $boolean);
20
21
        return $this;
22
    }
23
24
    /**
25
     * Use a 'wildcard' like search to several attributes for a match.
26
     *
27
     * @param  string  $search
28
     * @return $this
29
     */
30
    public function whereAddressLike(string $search): self
31
    {
32
        $this->where(function (self $builder) use ($search) {
33
            $builder->whereLike('address_1', $search);
34
            $builder->orWhereLike('address_2', $search);
35
            $builder->orWhereLike('city', $search);
36
            $builder->orWhereLike('state', $search);
37
            $builder->orWhereLike('zip', $search);
38
        });
39
40
        return $this;
41
    }
42
}
43