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\ExampleValue;
6use Apie\Core\Attributes\FakeMethod;
7use Apie\Core\ValueObjects\Interfaces\HasRegexValueObjectInterface;
8use Faker\Generator;
9
10#[FakeMethod('createRandom')]
11#[Description('Strict mime type without wildcards, for example "application/json"')]
12#[ExampleValue('application/json', 'JSON data')]
13#[ExampleValue('text/html', 'HTML document')]
14final class StrictMimeType implements HasRegexValueObjectInterface
15{
16    use IsStringWithRegexValueObject;
17
18    public static function getRegularExpression(): string
19    {
20        return '~^[a-zA-Z0-9!#$&^_.+-]+/[a-zA-Z0-9!#$&^_.+-]+$~';
21    }
22
23    public static function createRandom(Generator $faker): static
24    {
25        return new static($faker->mimeType());
26    }
27}