ResourceFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace kalanis\Restful;
4
5
6
use kalanis\Restful\Converters\ResourceConverter;
7
use kalanis\Restful\Exceptions\InvalidStateException;
8
9
10
/**
11
 * ResourceFactory
12
 * @package kalanis\Restful
13
 */
14 1
class ResourceFactory implements IResourceFactory
15
{
16 1
    public function __construct(
17
        private readonly ResourceConverter $resourceConverter,
18
    )
19
    {
20 1
    }
21
22
    /**
23
     * Create new API resource
24
     * @param array<string, mixed> $data
25
     * @throws InvalidStateException If Accept header is unknown
26
     * @return IResource
27
     */
28
    public function create(array $data = []): IResource
29
    {
30 1
        return new ConvertedResource($this->resourceConverter, $data);
31
    }
32
}
33