Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
StrictMimeType
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 getRegularExpression
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createRandom
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2namespace Apie\Core\ValueObjects;
3
4use Apie\Core\Attributes\Description;
5use Apie\Core\Attributes\FakeMethod;
6use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface;
7use Faker\Generator;
8
9#[FakeMethod('createRandom')]
10#[Description('Strict mime type without wildcards, for example "application/json"')]
11final class StrictMimeType implements HasRegexValueObjectInterface
12{
13    use IsStringWithRegexValueObject;
14
15    public static function getRegularExpression(): string
16    {
17        return '~^[a-zA-Z0-9!#$&^_.+-]+/[a-zA-Z0-9!#$&^_.+-]+$~';
18    }
19
20    public static function createRandom(Generator $faker): static
21    {
22        return new static($faker->mimeType());
23    }
24}