ContactRepository::findByCity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace TarfinLabs\Parasut\Repositories;
4
5
use TarfinLabs\Parasut\Enums\ResourceNames;
6
use TarfinLabs\Parasut\Models\Contact;
7
use TarfinLabs\Parasut\Repositories\Meta\BaseMeta;
8
use TarfinLabs\Parasut\Repositories\Meta\ContactMeta;
9
10
class ContactRepository extends BaseRepository
11
{
12
    protected string $endpoint = ResourceNames::CONTACT;
13
    protected string $model = Contact::class;
14
15
    // region Sorts
16
17
    public function sortById(bool $descending = false): self
18
    {
19
        return $this->sortByAttribute('id', $descending);
20
    }
21
22
    public function sortByBalance(bool $descending = false): self
23
    {
24
        return $this->sortByAttribute('balance', $descending);
25
    }
26
27
    public function sortByName(bool $descending = false): self
28
    {
29
        return $this->sortByAttribute('name', $descending);
30
    }
31
32
    public function sortByEmail(bool $descending = false): self
33
    {
34
        return $this->sortByAttribute('email', $descending);
35
    }
36
37
    // endregion
38
39
    // region Filters
40
41
    public function findByName(string $name): self
42
    {
43
        $this->filters['name'] = $name;
44
45
        return $this;
46
    }
47
48
    public function findByEmail(string $email): self
49
    {
50
        $this->filters['email'] = $email;
51
52
        return $this;
53
    }
54
55
    public function findByTaxNumber(string $taxNumber): self
56
    {
57
        $this->filters['tax_number'] = $taxNumber;
58
59
        return $this;
60
    }
61
62
    public function findByTaxOffice(string $taxOffice): self
63
    {
64
        $this->filters['tax_office'] = $taxOffice;
65
66
        return $this;
67
    }
68
69
    public function findByCity(string $city): self
70
    {
71
        $this->filters['city'] = $city;
72
73
        return $this;
74
    }
75
76
    // endregion
77
78
    // region Includes
79
80
    public function includeCategory(): self
81
    {
82
        $this->includes[] = 'category';
83
84
        return $this;
85
    }
86
87
    public function includeContactPortal(): self
88
    {
89
        $this->includes[] = 'contact_portal';
90
91
        return $this;
92
    }
93
94
    public function includeContactPeople(): self
95
    {
96
        $this->includes[] = 'contact_people';
97
98
        return $this;
99
    }
100
101
    // endregion
102
103
    // region Meta
104
105 1
    protected static function createMeta(array $meta): BaseMeta
106
    {
107 1
        return new ContactMeta($meta);
108
    }
109
110
    // endregion
111
}
112