Passed
Push — master ( 8c1a6c...28368a )
by Yunus Emre
03:25
created

ContactRepository::createMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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