Test Failed
Push — master ( 257d98...3364ef )
by Yunus Emre
06:12
created

ContactRepository::sortByBalance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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