Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
ValueObjectStrategy
80.00% covered (warning)
80.00%
4 / 5
80.00% covered (warning)
80.00%
4 / 5
5.20
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 supports
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getCreationMetadata
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getModificationMetadata
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getResultMetadata
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\Metadata\Strategy;
3
4use Apie\Core\Context\ApieContext;
5use Apie\Core\Metadata\StrategyInterface;
6use Apie\Core\Metadata\ValueObjectMetadata;
7use Apie\Core\Utils\ValueObjectUtils;
8use Apie\Core\ValueObjects\Interfaces\ValueObjectInterface;
9use ReflectionClass;
10
11final class ValueObjectStrategy implements StrategyInterface
12{
13    /**
14     * @param ReflectionClass<ValueObjectInterface> $class
15     */
16    public function __construct(private ReflectionClass $class)
17    {
18    }
19
20    public static function supports(ReflectionClass $class): bool
21    {
22        return ValueObjectUtils::isNonCompositeValueObject($class);
23    }
24
25    public function getCreationMetadata(ApieContext $context): ValueObjectMetadata
26    {
27        return new ValueObjectMetadata($this->class);
28    }
29
30    public function getModificationMetadata(ApieContext $context): ValueObjectMetadata
31    {
32        return $this->getCreationMetadata($context);
33    }
34
35    public function getResultMetadata(ApieContext $context): ValueObjectMetadata
36    {
37        return $this->getCreationMetadata($context);
38    }
39}