Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
CompanyName | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
getRegularExpression | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
convert | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
createRandom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\TextValueObjects; |
3 | |
4 | use Apie\Core\Attributes\Description; |
5 | use Apie\Core\Attributes\FakeMethod; |
6 | use Apie\Core\Attributes\ProvideIndex; |
7 | use Apie\Core\ValueObjects\Concerns\IndexesWords; |
8 | use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface; |
9 | use Apie\Core\ValueObjects\IsStringWithRegexValueObject; |
10 | use Faker\Generator; |
11 | |
12 | #[FakeMethod('createRandom')] |
13 | #[ProvideIndex('getIndexes')] |
14 | #[Description('Represents a company name.')] |
15 | class CompanyName implements HasRegexValueObjectInterface |
16 | { |
17 | use IndexesWords; |
18 | use IsStringWithRegexValueObject; |
19 | |
20 | public static function getRegularExpression(): string |
21 | { |
22 | return '/^\w[\w\-\s\'`"‘’“”‟,]*$/u'; |
23 | } |
24 | |
25 | protected function convert(string $input): string |
26 | { |
27 | return trim($input); |
28 | } |
29 | |
30 | public static function createRandom(Generator $generator): self |
31 | { |
32 | return self::fromNative($generator->company()); |
33 | } |
34 | } |