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\Description; |
5 | use Apie\Core\Attributes\FakeMethod; |
6 | use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface; |
7 | use Apie\Core\ValueObjects\Interfaces\LengthConstraintStringValueObjectInterface; |
8 | use Faker\Generator; |
9 | |
10 | #[FakeMethod('createRandom')] |
11 | #[Description('A file name with extension, but without path')] |
12 | final class Filename implements HasRegexValueObjectInterface, LengthConstraintStringValueObjectInterface |
13 | { |
14 | use IsStringWithRegexValueObject; |
15 | |
16 | public static function getRegularExpression(): string |
17 | { |
18 | return '/^(?=.{1,255}$)[^<>:"\/\\|?*\x00-\x1F\x7F]+(\.[^<>:"\/\\|?*\x00-\x1F\x7F]+)?$/'; |
19 | } |
20 | |
21 | public static function minStringLength(): int |
22 | { |
23 | return 1; |
24 | } |
25 | |
26 | public static function maxStringLength(): int |
27 | { |
28 | return 255; |
29 | } |
30 | |
31 | public static function createRandom(Generator $generator): static |
32 | { |
33 | return new static($generator->word() . '.' . $generator->fileExtension()); |
34 | } |
35 | } |