Passed
Push — master ( 57d086...37e761 )
by Chris
14:26
created

CommentCollection::contrast()   A

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
namespace Leonidas\Library\System\Model\Comment;
4
5
use Leonidas\Contracts\System\Model\Comment\CommentCollectionInterface;
6
use Leonidas\Contracts\System\Model\Comment\CommentInterface;
7
use Leonidas\Library\System\Model\Abstracts\AbstractModelCollection;
8
use Leonidas\Library\System\Model\Abstracts\PoweredByModelCollectionKernelTrait;
9
10
class CommentCollection extends AbstractModelCollection implements CommentCollectionInterface
11
{
12
    use PoweredByModelCollectionKernelTrait;
13
14
    public function __construct(CommentInterface ...$comments)
15
    {
16
        $this->initKernel($comments);
17
    }
18
19
    public function collect(CommentInterface ...$comments): void
20
    {
21
        $this->kernel->collect($comments);
22
    }
23
24
    public function add(CommentInterface $comment): void
25
    {
26
        $this->kernel->insert($comment);
27
    }
28
29
    public function hasWithId(int ...$id): bool
30
    {
31
        return $this->kernel->hasWhere('id', 'in', $id);
32
    }
33
34
    public function hasWith(string $property, ...$values): bool
35
    {
36
        return $this->kernel->hasWhere($property, 'in', $values);
37
    }
38
39
    public function hasWhere(string $property, string $operator, $value): bool
40
    {
41
        return $this->kernel->hasWhere($property, $operator, $value);
42
    }
43
44
    public function matches(CommentCollectionInterface $comments): bool
45
    {
46
        return $this->kernel->matches($comments->toArray());
47
    }
48
49
    public function getById(int $id): ?CommentInterface
50
    {
51
        return $this->kernel->firstWhere('id', '=', $id);
52
    }
53
54
    public function getBy(string $property, $value): ?CommentInterface
55
    {
56
        return $this->kernel->firstWhere($property, '=', $value);
57
    }
58
59
    public function firstWhere(string $property, string $operator, $value): ?CommentInterface
60
    {
61
        return $this->kernel->firstWhere($property, $operator, $value);
62
    }
63
64
    public function first(): ?CommentInterface
65
    {
66
        return $this->kernel->first();
67
    }
68
69
    public function last(): ?CommentInterface
70
    {
71
        return $this->kernel->last();
72
    }
73
74
    public function withId(int ...$id): CommentCollection
75
    {
76
        return $this->kernel->where('id', 'in', $id);
77
    }
78
79
    public function withoutId(int ...$id): CommentCollection
80
    {
81
        return $this->kernel->where('id', 'not in', $id);
82
    }
83
84
    public function with(string $property, ...$values): CommentCollection
85
    {
86
        return $this->kernel->where($property, 'in', $values);
87
    }
88
89
    public function without(string $property, ...$values): CommentCollection
90
    {
91
        return $this->kernel->where($property, 'not in', $values);
92
    }
93
94
    public function where(string $property, string $operator, $value): CommentCollection
95
    {
96
        return $this->kernel->where($property, $operator, $value);
97
    }
98
99
    public function filter(callable $callback): CommentCollection
100
    {
101
        return $this->kernel->filter($callback);
102
    }
103
104
    public function diff(CommentCollectionInterface ...$comments): CommentCollection
105
    {
106
        return $this->kernel->diff(...$this->expose(...$comments));
107
    }
108
109
    public function contrast(CommentCollectionInterface ...$comments): CommentCollection
110
    {
111
        return $this->kernel->contrast(...$this->expose(...$comments));
112
    }
113
114
    public function intersect(CommentCollectionInterface ...$comments): CommentCollection
115
    {
116
        return $this->kernel->intersect(...$this->expose(...$comments));
117
    }
118
119
    public function merge(CommentCollectionInterface ...$comments): CommentCollection
120
    {
121
        return $this->kernel->merge(...$this->expose(...$comments));
122
    }
123
124
    public function sortBy(string $property, string $order = 'asc'): CommentCollection
125
    {
126
        return $this->kernel->sortBy($property, $order);
127
    }
128
129
    public function sortMapped(array $map, string $property, string $order = 'asc'): CommentCollection
130
    {
131
        return $this->kernel->sortMapped($map, $property, $order);
132
    }
133
134
    public function sortCustom(callable $callback, string $order = 'asc'): CommentCollection
135
    {
136
        return $this->kernel->sortCustom($callback, $order);
137
    }
138
}
139