Passed
Push — master ( e79858...61a477 )
by Chris
07:44
created

FlaggableJsonSerializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A serialize() 0 3 1
1
<?php
2
3
namespace WebTheory\Collection\Json;
4
5
use WebTheory\Collection\Contracts\JsonSerializerInterface;
6
7
class FlaggableJsonSerializer implements JsonSerializerInterface
8
{
9
    protected int $flags;
10
11
    public function __construct(int $flags = 0)
12
    {
13
        $this->flags = $flags;
14
    }
15
16
    public function serialize(array $items): string
17
    {
18
        return json_encode($items, JSON_THROW_ON_ERROR | $this->flags);
19
    }
20
}
21