Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
FormFieldProperty
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 getFallbackText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createForProperty
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\Translator\ValueObjects;
3
4use Apie\Core\BoundedContext\BoundedContextId;
5use Apie\Core\Identifiers\SnakeCaseSlug;
6use Apie\Core\Lists\ItemHashmap;
7use Apie\Core\Lists\StringList;
8
9final class FormFieldProperty extends AbstractTranslation
10{
11    protected const MIDDLE_REGEX = '[^.]+(\.[^.]+)*';
12
13    public function getFallbackText(): string
14    {
15        return strstr($this->middleSection, '.');
16    }
17
18    /**
19     * @param \ReflectionClass<object> $class
20     */
21    public static function createForProperty(
22        StringList $list,
23        \ReflectionClass $class,
24        ?BoundedContextId $boundedContextId = null
25    ): static {
26        return new FormFieldProperty(
27            new TranslationStringPrefix($boundedContextId, SnakeCaseSlug::fromClass($class)),
28            $list->join('.'),
29            new TranslationStringSuffix(),
30            new ItemHashmap()
31        );
32    }
33}