Passed
Pull Request — main (#19)
by Chema
02:23
created

JsonResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 12
ccs 5
cts 5
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Router\Entities;
6
7
final class JsonResponse
8
{
9 1
    public function __construct(
10
        private array $json,
11
    ) {
12 1
    }
13
14 1
    public function __toString(): string
15
    {
16 1
        header('Content-Type: application/json');
17
18 1
        return json_encode($this->json, JSON_THROW_ON_ERROR);
19
    }
20
}
21