Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
50.00% |
2 / 4 |
|
50.00% |
2 / 4 |
CRAP | |
0.00% |
0 / 1 |
Filename | |
50.00% |
2 / 4 |
|
50.00% |
2 / 4 |
6.00 | |
0.00% |
0 / 1 |
getRegularExpression | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
minStringLength | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
maxStringLength | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
createRandom | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Apie\Core\ValueObjects; |
3 | |
4 | use Apie\Core\Attributes\FakeMethod; |
5 | use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface; |
6 | use Apie\Core\ValueObjects\Interfaces\LengthConstraintStringValueObjectInterface; |
7 | use Faker\Generator; |
8 | |
9 | #[FakeMethod('createRandom')] |
10 | final class Filename implements HasRegexValueObjectInterface, LengthConstraintStringValueObjectInterface |
11 | { |
12 | use IsStringWithRegexValueObject; |
13 | |
14 | public static function getRegularExpression(): string |
15 | { |
16 | return '/^(?=.{1,255}$)[^<>:"\/\\|?*\x00-\x1F\x7F]+(\.[^<>:"\/\\|?*\x00-\x1F\x7F]+)?$/'; |
17 | } |
18 | |
19 | public static function minStringLength(): int |
20 | { |
21 | return 1; |
22 | } |
23 | |
24 | public static function maxStringLength(): int |
25 | { |
26 | return 255; |
27 | } |
28 | |
29 | public static function createRandom(Generator $generator): static |
30 | { |
31 | return new static($generator->word() . '.' . $generator->fileExtension()); |
32 | } |
33 | } |