Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
BoundedContext
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
6
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 contains
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\BoundedContext;
3
4use Apie\Core\Entities\EntityInterface;
5use Apie\Core\Lists\ReflectionClassList;
6use Apie\Core\Lists\ReflectionMethodList;
7use ReflectionClass;
8
9final class BoundedContext implements EntityInterface
10{
11    public readonly BoundedContextId $id;
12
13    public function __construct(
14        BoundedContextId|string $id,
15        public readonly ReflectionClassList $resources,
16        public readonly ReflectionMethodList $actions,
17    ) {
18        $this->id = $id instanceof BoundedContextId ? $id : new BoundedContextId($id);
19    }
20
21    /**
22     * @param ReflectionClass<object> $resourceClass
23     */
24    public function contains(ReflectionClass $resourceClass): bool
25    {
26        foreach ($this->resources as $resource) {
27            if ($resource->name === $resourceClass->name) {
28                return true;
29            }
30        }
31
32        return false;
33    }
34
35    public function getId(): BoundedContextId
36    {
37        return $this->id;
38    }
39}