ApplicationInfoRetriever   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 65
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A retrieve() 0 7 1
A retrieveAll() 0 7 1
1
<?php
2
3
namespace Apie\ApplicationInfoPlugin\DataLayers;
4
5
use Apie\ApplicationInfoPlugin\ApiResources\ApplicationInfo;
6
use Apie\Core\Interfaces\ApiResourceRetrieverInterface;
7
use Apie\Core\SearchFilters\SearchFilterRequest;
8
9
/**
10
 * Retrieves instances of api resource ApplicationInfo. This is always one record.
11
 */
12
class ApplicationInfoRetriever implements ApiResourceRetrieverInterface
13
{
14
    /**
15
     * @var string
16
     */
17
    private $appName;
18
19
    /**
20
     * @var string
21
     */
22
    private $environment;
23
24
    /**
25
     * @var string
26
     */
27
    private $hash;
28
29
    /**
30
     * @var bool
31
     */
32
    private $debug;
33
34
    /**
35
     * @param string $appName
36
     * @param string $environment
37
     * @param string $hash
38
     * @param bool $debug
39
     */
40
    public function __construct(string $appName, string $environment, string $hash, bool $debug)
41
    {
42
        $this->appName = $appName;
43
        $this->environment = $environment;
44
        $this->hash = $hash;
45
        $this->debug = $debug;
46
    }
47
48
    /**
49
     * @param string $resourceClass
50
     * @param string $id
51
     * @param array $context
52
     * @return ApplicationInfo
53
     */
54
    public function retrieve(string $resourceClass, $id, array $context)
55
    {
56
        return new ApplicationInfo(
57
            $this->appName,
58
            $this->environment,
59
            $this->hash,
60
            $this->debug
61
        );
62
    }
63
64
    /**
65
     * @param string $resourceClass
66
     * @param array $context
67
     * @param SearchFilterRequest $searchFilterRequest
68
     * @return ApplicationInfo[]
69
     */
70
    public function retrieveAll(
71
        string $resourceClass,
72
        array $context,
73
        SearchFilterRequest $searchFilterRequest
74
    ): iterable {
75
        return [
76
            $this->retrieve($resourceClass, '', $context)
77
        ];
78
    }
79
}
80