| Total Complexity | 2 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | abstract class AbstractResource |
||
| 15 | { |
||
| 16 | public const NUMERIC_ID = '(?P<id>[\d]+)'; |
||
| 17 | public const ALNUM_ID = '(?P<id>[\w]+)'; |
||
| 18 | |||
| 19 | public ?string $id; |
||
| 20 | |||
| 21 | /** @var ResourceOperationInterface[] */ |
||
| 22 | protected array $operations = []; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Returns path of the resource |
||
| 26 | * |
||
| 27 | * @return string |
||
| 28 | * @example '/resources/' |
||
| 29 | * @example '/resources/' . $this->id ?? self::NUMERIC_ID |
||
| 30 | */ |
||
| 31 | abstract public function getPath(): string; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Adds given operation to the resource |
||
| 35 | * |
||
| 36 | * @param ResourceOperationInterface $operation |
||
| 37 | */ |
||
| 38 | public function addOperation(ResourceOperationInterface $operation): void |
||
| 39 | { |
||
| 40 | $operation->setResource($this); |
||
| 41 | $this->operations[] = $operation; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @return ResourceOperationInterface[]|Collection |
||
| 46 | */ |
||
| 47 | public function getOperations(): Collection |
||
| 50 | } |
||
| 51 | } |
||
| 52 |