Passed
Push — main ( 053125...2aad05 )
by Chema
57s queued 15s
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 4
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 __toString() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Gacela\Router\Entities;
6
7
final class JsonResponse extends Response
8
{
9 1
    public function __construct(array $json)
10
    {
11 1
        parent::__construct(json_encode($json, JSON_THROW_ON_ERROR));
12
    }
13
14 1
    public function __toString(): string
15
    {
16 1
        header('Content-Type: application/json');
17
18 1
        return parent::__toString();
19
    }
20
}
21