File size: 2,496 Bytes
cf14c12
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php

declare(strict_types=1);

namespace Preset\Domain\Repositories;

use Category\Domain\Entities\CategoryEntity;
use Iterator;
use Preset\Domain\Entities\PresetEntity;
use Preset\Domain\Exceptions\PresetNotFoundException;
use Preset\Domain\ValueObjects\SortParameter;
use Preset\Domain\ValueObjects\Status;
use Preset\Domain\ValueObjects\Template;
use Preset\Domain\ValueObjects\Type;
use Shared\Domain\Repositories\RepositoryInterface;
use Shared\Domain\ValueObjects\Id;
use Shared\Domain\ValueObjects\SortDirection;

interface PresetRepositoryInterface extends RepositoryInterface
{
    /**
     * @param PresetEntity $preset 
     * @return static 
     */
    public function add(PresetEntity $preset): static;

    /**
     * @param PresetEntity $preset 
     * @return static 
     */
    public function remove(PresetEntity $preset): static;

    /**
     * @param Id $id 
     * @return PresetEntity 
     * @throws PresetNotFoundException
     */
    public function ofId(Id $id): PresetEntity;

    /**
     * @param Template $template 
     * @return null|PresetEntity 
     */
    public function ofTemplate(Template $template): ?PresetEntity;

    /**
     * @param Status $status 
     * @return static 
     */
    public function filterByStatus(Status $status): static;

    /**
     * @param Type $type 
     * @return static 
     */
    public function filterByType(Type $type): static;

    /**
     * @param bool $isLocked 
     * @return static 
     */
    public function filterByLock(bool $isLocked): static;

    /**
     * @param Id|CategoryEntity $category 
     * @return static 
     */
    public function filterByCategory(Id|CategoryEntity $category): static;

    /**
     * @param Id|array<Id> $ids
     * @return static
     */
    public function filterById(Id|array $ids): static;

    /**
     * @param string $query 
     * @return static 
     */
    public function search(string $query): static;

    /**
     * @param SortDirection $dir 
     * @param null|SortParameter $sortParameter 
     * @return static 
     */
    public function sort(
        SortDirection $dir,
        ?SortParameter $sortParameter = null
    ): static;

    /**
     * @param PresetEntity $cursor 
     * @return Iterator<PresetEntity>
     */
    public function startingAfter(PresetEntity $cursor): Iterator;

    /**
     * @param PresetEntity $cursor 
     * @return Iterator<PresetEntity>
     */
    public function endingBefore(PresetEntity $cursor): Iterator;
}