RemotePlusResponse   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllValuesForItem() 0 11 2
A getResponses() 0 2 1
A addResponse() 0 2 1
A __construct() 0 1 1
A getByIdentifier() 0 2 1
1
<?php
2
3
namespace DPRMC\IceRemotePlusClient;
4
5
6
/**
7
 * A wrapper class around a bunch of SecurityResponse objects. This represents all of the data returned by RemotePlus.
8
 * Class RemotePlusResponse
9
 * @package DPRMC\IceRemotePlusClient
10
 */
11
class RemotePlusResponse {
12
13
    /**
14
     * @var array An array of SecurityResponse objects.
15
     */
16
    protected $responses = [];
17
18
    /**
19
     * RemotePlusResponse constructor.
20
     */
21
    public function __construct() {
22
    }
23
24
    /**
25
     * "Setter" method to add a SecurityResponse object to our array of objects.
26
     * @param SecurityResponse $response
27
     */
28
    public function addResponse( SecurityResponse $response ){
29
        $this->responses[$response->identifier] = $response;
30
    }
31
32
    /**
33
     * Simple getter method to get an array of all the SecurityResponse objects.
34
     * @return array
35
     */
36
    public function getResponses(){
37
        return $this->responses;
38
    }
39
40
41
    /**
42
     * Pass an item code into this method, and it will return an array of identifier => itemValue. A convenience method.
43
     * @param string $item
44
     * @return array
45
     */
46
    public function getAllValuesForItem(string $item): array{
47
        $valuesToReturn = [];
48
49
        /**
50
         * @var SecurityResponse $response
51
         */
52
        foreach($this->responses as $response):
53
            $valuesToReturn[$response->identifier] = $response->items[$item];
54
        endforeach;
55
56
        return $valuesToReturn;
57
    }
58
59
    /**
60
     * Getter method to return the SecurityResponse object for a given security's data set.
61
     * @param string $identifier
62
     * @return SecurityResponse
63
     */
64
    public function getByIdentifier(string $identifier): SecurityResponse{
65
        return $this->responses[$identifier];
66
    }
67
68
}