Passed
Branch 3.0.0 (dcfee6)
by Pieter
02:48
created

NullDataLayer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 39
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A persistNew() 0 3 1
A persistExisting() 0 3 1
A remove() 0 2 1
A retrieveAll() 0 3 1
A retrieve() 0 3 1
1
<?php
2
namespace W2w\Lib\Apie\Plugins\Core\DataLayers;
3
4
use W2w\Lib\Apie\Core\SearchFilters\SearchFilterRequest;
5
use W2w\Lib\Apie\Exceptions\ResourceNotFoundException;
6
use W2w\Lib\Apie\Interfaces\ApiResourcePersisterInterface;
7
use W2w\Lib\Apie\Interfaces\ApiResourceRetrieverInterface;
8
9
/**
10
 * Persists and retrieves nothing. Only created for entities that require POST, but do not need any storage.
11
 */
12
class NullDataLayer implements ApiResourcePersisterInterface, ApiResourceRetrieverInterface
13
{
14
    /**
15
     * {@inheritDoc}
16
     */
17
    public function persistNew($resource, array $context = [])
18
    {
19
        return $resource;
20
    }
21
22
    /**
23
     * {@inheritDoc}
24
     */
25
    public function persistExisting($resource, $int, array $context = [])
26
    {
27
        return $resource;
28
    }
29
30
    /**
31
     * {@inheritDoc}
32
     */
33
    public function remove(string $resourceClass, $id, array $context)
34
    {
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40
    public function retrieve(string $resourceClass, $id, array $context)
41
    {
42
        throw new ResourceNotFoundException($id);
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48
    public function retrieveAll(string $resourceClass, array $context, SearchFilterRequest $searchFilterRequest
49
    ): iterable {
50
        return [];
51
    }
52
}
53