AbstractImageCollection::matches()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Leonidas\Library\System\Model\Image\Abstracts;
6
7
use Leonidas\Contracts\System\Model\Image\ImageCollectionInterface;
8
use Leonidas\Contracts\System\Model\Image\ImageInterface;
9
use Leonidas\Library\System\Model\Abstracts\AbstractModelCollection;
10
11
abstract class AbstractImageCollection extends AbstractModelCollection implements ImageCollectionInterface
12
{
13
    public function collect(ImageInterface ...$images): void
14
    {
15
        $this->kernel->collect($images);
16
    }
17
18
    public function add(ImageInterface $image): void
19
    {
20
        $this->kernel->insert($image);
21
    }
22
23
    public function hasWithId(int ...$id): bool
24
    {
25
        return $this->kernel->hasWhere('id', 'in', $id);
26
    }
27
28
    public function hasWithName(string ...$name): bool
29
    {
30
        return $this->kernel->hasWhere('name', 'in', $name);
31
    }
32
33
    public function hasWithSrc(string ...$src): bool
34
    {
35
        return $this->kernel->hasWhere('src', 'in', $src);
36
    }
37
38
    public function hasWith(string $property, ...$values): bool
39
    {
40
        return $this->kernel->hasWhere($property, 'in', $values);
41
    }
42
43
    public function hasWhere(string $property, string $operator, $value): bool
44
    {
45
        return $this->kernel->hasWhere($property, $operator, $value);
46
    }
47
48
    public function matches(ImageCollectionInterface $images): bool
49
    {
50
        return $this->kernel->matches($images->toArray());
51
    }
52
53
    public function getById(int $id): ?ImageInterface
54
    {
55
        return $this->kernel->firstWhere('id', '=', $id);
56
    }
57
58
    public function getByName(string $name): ?ImageInterface
59
    {
60
        return $this->kernel->firstWhere('name', '=', $name);
61
    }
62
63
    public function getBySrc(string $src): ?ImageInterface
64
    {
65
        return $this->kernel->firstWhere('src', '=', $src);
66
    }
67
68
    public function getBy(string $property, $value): ?ImageInterface
69
    {
70
        return $this->kernel->firstWhere($property, '=', $value);
71
    }
72
73
    public function firstWhere(string $property, string $operator, $value): ?ImageInterface
74
    {
75
        return $this->kernel->firstWhere($property, $operator, $value);
76
    }
77
78
    public function first(): ?ImageInterface
79
    {
80
        return $this->kernel->first();
81
    }
82
83
    public function last(): ?ImageInterface
84
    {
85
        return $this->kernel->last();
86
    }
87
88
    public function withId(int ...$id): AbstractImageCollection
89
    {
90
        return $this->kernel->where('id', 'in', $id);
91
    }
92
93
    public function withoutId(int ...$id): AbstractImageCollection
94
    {
95
        return $this->kernel->where('id', 'not in', $id);
96
    }
97
98
    public function withName(string ...$name): AbstractImageCollection
99
    {
100
        return $this->kernel->where('name', 'in', $name);
101
    }
102
103
    public function withoutName(string ...$name): AbstractImageCollection
104
    {
105
        return $this->kernel->where('name', 'not in', $name);
106
    }
107
108
    public function withSrc(string ...$src): AbstractImageCollection
109
    {
110
        return $this->kernel->where('src', 'in', $src);
111
    }
112
113
    public function withoutSrc(string ...$src): AbstractImageCollection
114
    {
115
        return $this->kernel->where('src', 'not in', $src);
116
    }
117
118
    public function with(string $property, ...$values): AbstractImageCollection
119
    {
120
        return $this->kernel->where($property, 'in', $values);
121
    }
122
123
    public function without(string $property, ...$values): AbstractImageCollection
124
    {
125
        return $this->kernel->where($property, 'not in', $values);
126
    }
127
128
    public function where(string $property, string $operator, $value): AbstractImageCollection
129
    {
130
        return $this->kernel->where($property, $operator, $value);
131
    }
132
133
    public function filter(callable $callback): AbstractImageCollection
134
    {
135
        return $this->kernel->filter($callback);
136
    }
137
138
    public function diff(ImageCollectionInterface ...$images): AbstractImageCollection
139
    {
140
        return $this->kernel->diff(...$this->expose(...$images));
141
    }
142
143
    public function contrast(ImageCollectionInterface ...$images): AbstractImageCollection
144
    {
145
        return $this->kernel->contrast(...$this->expose(...$images));
146
    }
147
148
    public function intersect(ImageCollectionInterface ...$images): AbstractImageCollection
149
    {
150
        return $this->kernel->intersect(...$this->expose(...$images));
151
    }
152
153
    public function merge(ImageCollectionInterface ...$images): AbstractImageCollection
154
    {
155
        return $this->kernel->merge(...$this->expose(...$images));
156
    }
157
158
    public function sortBy(string $property, string $order = 'asc'): AbstractImageCollection
159
    {
160
        return $this->kernel->sortBy($property, $order);
161
    }
162
163
    public function sortMappedById(array $map, string $order = 'asc'): AbstractImageCollection
164
    {
165
        return $this->kernel->sortMapped($map, 'id', $order);
166
    }
167
168
    public function sortMappedByName(array $map, string $order = 'asc'): AbstractImageCollection
169
    {
170
        return $this->kernel->sortMapped($map, 'name', $order);
171
    }
172
173
    public function sortMapped(array $map, string $property, string $order = 'asc'): AbstractImageCollection
174
    {
175
        return $this->kernel->sortMapped($map, $property, $order);
176
    }
177
178
    public function sortCustom(callable $callback, string $order = 'asc'): AbstractImageCollection
179
    {
180
        return $this->kernel->sortCustom($callback, $order);
181
    }
182
}
183