-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAllowCreateFrom.php
More file actions
28 lines (25 loc) · 892 Bytes
/
AllowCreateFrom.php
File metadata and controls
28 lines (25 loc) · 892 Bytes
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
<?php
namespace Bottledcode\DurablePhp\State\Attributes;
use Attribute;
use Bottledcode\DurablePhp\State\EntityId;
use Bottledcode\DurablePhp\State\EntityState;
use Bottledcode\DurablePhp\State\OrchestrationInstance;
use LogicException;
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_ALL)]
class AllowCreateFrom implements AccessControl
{
/**
* @template T of EntityState
*
* @param class-string<T> $type
*/
public function __construct(public ?string $type = null, public EntityId|OrchestrationInstance|null $id = null)
{
if ($type === null && $id === null) {
throw new LogicException('At least one of type or id must be provided to AllowCreateFrom');
}
if ($type !== null && $id !== null) {
throw new LogicException('Only one of type or id can be provided to AllowCreateFrom');
}
}
}