StringableMediaType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 3 1
A __toString() 0 3 1
A getIdentifier() 0 3 1
1
<?php
2
3
/**
4
 * It's free open-source software released under the MIT License.
5
 *
6
 * @author Anatoly Nekhay <[email protected]>
7
 * @copyright Copyright (c) 2018, Anatoly Nekhay
8
 * @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
9
 * @link https://github.com/sunrise-php/http-router
10
 */
11
12
declare(strict_types=1);
13
14
namespace Sunrise\Http\Router;
15
16
use Stringable;
17
use Sunrise\Coder\MediaTypeInterface;
18
19
/**
20
 * @since 3.0.0
21
 */
22
final class StringableMediaType implements MediaTypeInterface, Stringable
23
{
24 2
    public function __construct(
25
        private readonly MediaTypeInterface $mediaType,
26
    ) {
27 2
    }
28
29 2
    public static function create(MediaTypeInterface $mediaType): self
30
    {
31 2
        return new self($mediaType);
32
    }
33
34 2
    public function getIdentifier(): string
35
    {
36 2
        return $this->mediaType->getIdentifier();
37
    }
38
39 2
    public function __toString(): string
40
    {
41 2
        return $this->getIdentifier();
42
    }
43
}
44