-
Notifications
You must be signed in to change notification settings - Fork 4
/
DomainCollection.php
65 lines (54 loc) · 1.11 KB
/
DomainCollection.php
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
<?php
declare(strict_types=1);
namespace MsgPhp\Domain;
/**
* @author Roland Franssen <[email protected]>
*
* @template TKey of array-key
* @template T
* @extends \IteratorAggregate<TKey, T>
*/
interface DomainCollection extends \Countable, \IteratorAggregate
{
public function isEmpty(): bool;
/**
* @param T $element
*/
public function contains($element): bool;
/**
* @param TKey $key
*/
public function containsKey($key): bool;
/**
* @return T
*/
public function first();
/**
* @return T
*/
public function last();
/**
* @param TKey $key
*
* @return T
*/
public function get($key);
/**
* @param callable(T):bool $filter
*
* @return static<TKey, T>
*/
public function filter(callable $filter): self;
/**
* @return static<TKey, T>
*/
public function slice(int $offset, int $limit = 0): self;
/**
* @template T2
*
* @param callable(T):T2 $mapper
*
* @return static<TKey, T2>
*/
public function map(callable $mapper): self;
}