-
Notifications
You must be signed in to change notification settings - Fork 0
/
PermissionableEntitiesCollectionInterface.php
102 lines (90 loc) · 3.94 KB
/
PermissionableEntitiesCollectionInterface.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
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
<?php
declare(strict_types=1);
namespace VersatileAcl\Interfaces;
interface PermissionableEntitiesCollectionInterface extends CollectionInterface {
/**
* Constructor.
*
* @param PermissionableEntityInterface ...$permissionEntities zero or more instances of PermissionableEntityInterface to be added to this collection
*
*/
public function __construct(PermissionableEntityInterface ...$permissionEntities);
/**
* Adds an instance of PermissionableEntityInterface to an instance of this interface.
* Duplicate PermissionableEntityInterface instances should not be allowed in the same instance of this interface.
*
*
*/
public function add(PermissionableEntityInterface $permissionEntity): self;
/**
* Adds an instance of PermissionableEntityInterface to an instance of this interface with the specified key.
*
* @param string $key specified key for $permissionEntity in the collection
*
*/
public function put(PermissionableEntityInterface $permissionEntity, string $key): self;
/**
* Removes an instance of PermissionableEntityInterface from an instance of this interface.
*
*
*/
public function remove(PermissionableEntityInterface $permissionEntity): self;
/**
* Remove all items in the collection and return $this
*/
public function removeAll(): self;
/**
* Find an entity in the collection matching the specified $entityId.
* Return NULL if no matching entity exists in the collection.
*
* The $entityId should be matched in a case-insensitive manner:
* - 'BoB', 'bOb' and 'bob' will all match an entity with the ID 'BOB'
*
* NOTE: The ID for an entity is what is returned by
* PermissionableEntityInterface::getId()
*
* @param string $entityId the ID of the entity we are searching for
*
* @return PermissionableEntityInterface|null an entity that matches the specified $entityId or NULL if such an entity was not found in the collection
*/
public function find(string $entityId): ?PermissionableEntityInterface;
/**
* Retrieves the entity in the collection associated with the specified collection key.
* If the key is not present in the collection, NULL should be returned
*
*
*/
public function get(string $key): ?PermissionableEntityInterface;
/**
* Retrieves the key in the collection associated with the specified object.
* If the object is not present in the collection, NULL should be returned
*
*
* @return string|int|null
*/
public function getKey(PermissionableEntityInterface $entity);
/**
* Checks whether or not an entity exists in the current instance.
*
* `$entity` is present in the current instance if there is another entity `$x`
* in the current instance where $x->isEqualTo($entity) === true.
*
*
* @return bool true if there is another entity `$x` in the current instance where $x->isEqualTo($entity) === true, otherwise return false
*/
public function has(PermissionableEntityInterface $entity): bool;
/**
* Sort the collection.
* If specified, use the callback to compare items in the collection when sorting or
* sort according to some default criteria (up to the implementer of this method to
* specify what that criteria is).
*
* @param callable|null $comparator has the following signature:
* function( PermissionableEntityInterface $a, PermissionableEntityInterface $b ) : int
* The comparison function must return an integer less than,
* equal to, or greater than zero if the first argument is
* considered to be respectively less than, equal to,
* or greater than the second.
*/
public function sort(callable $comparator=null): self;
}