NullDataLayer   A
last analyzed

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