GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Metadata::getResultVariableName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * @link https://github.com/old-town/workflow-zf2-service
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\ZF2\Service\Metadata\Storage;
7
8
/**
9
 * Class Metadata
10
 *
11
 * @package OldTown\Workflow\ZF2\Service\Metadata\Storage
12
 */
13
class Metadata implements MetadataInterface
14
{
15
    /**
16
     * Имя переменной в transientVars, в которую нужно сохранить результаты сервиса
17
     *
18
     * @var string|null
19
     */
20
    protected $resultVariableName;
21
22
    /**
23
     * Определяет можно ли перетирать уже существующую переменную
24
     *
25
     * @var bool
26
     */
27
    protected $allowOverrideResult = false;
28
29
    /**
30
     * Флаг определяет используется ли маппинг результатов
31
     *
32
     * @var bool
33
     */
34
    protected $flagUseResultMap = false;
35
36
    /**
37
     * Карта для наложения результатов работы сервиса в TransientVars
38
     *
39
     * @var array
40
     */
41
    protected $resultMap = [];
42
43
    /**
44
     * Хеши обеспечивающие уникальность данных используемых для маппинга результатов работы сервиса
45
     *
46
     * @var array
47
     */
48
    protected $resultMapHash = [];
49
50
    /**
51
     * Имя переменной в transientVars, в которую нужно сохранить результаты сервиса
52
     *
53
     * @return string|null
54
     */
55
    public function getResultVariableName()
56
    {
57
        return $this->resultVariableName;
58
    }
59
60
    /**
61
     * Устанавливает имя переменной в transientVars, в которую нужно сохранить результаты сервиса
62
     *
63
     * @param string $resultVariableName
64
     *
65
     * @return $this
66
     */
67
    public function setResultVariableName($resultVariableName)
68
    {
69
        $this->resultVariableName = (string)$resultVariableName;
70
71
        return $this;
72
    }
73
74
    /**
75
     * Определяет можно ли перетирать уже существующую переменную
76
     *
77
     * @return boolean
78
     */
79
    public function isAllowOverrideResult()
80
    {
81
        return $this->allowOverrideResult;
82
    }
83
84
    /**
85
     * Определяет можно ли перетирать уже существующую переменную
86
     *
87
     * @param boolean $allowOverrideResult
88
     *
89
     * @return $this
90
     */
91
    public function setAllowOverrideResult($allowOverrideResult)
92
    {
93
        $this->allowOverrideResult = (boolean)$allowOverrideResult;
94
95
        return $this;
96
    }
97
98
    /**
99
     * Флаг определяет используется ли маппинг результатов
100
     *
101
     * @return boolean
102
     */
103
    public function getFlagUseResultMap()
104
    {
105
        return $this->flagUseResultMap;
106
    }
107
108
    /**
109
     * Добавляет информацию о маппинге результатов работы функции
110
     *
111
     * @param ResultMapMetadataInterface $item
112
     *
113
     * @return $this
114
     *
115
     * @throws Exception\InvalidResultMapException
116
     */
117
    public function addResultMap(ResultMapMetadataInterface $item)
118
    {
119
        $key = $item->getFrom() . '_' . $item->getTo();
120
        if (array_key_exists($key, $this->resultMapHash)) {
121
            $errMsg = sprintf('Map for key %s already exists', $key);
122
            throw new Exception\InvalidResultMapException($errMsg);
123
        }
124
125
126
        $this->resultMap[$item->getFrom()] = $item;
127
        $this->resultMapHash[$key] = $key;
128
        $this->flagUseResultMap = true;
129
130
        return $this;
131
    }
132
133
    /**
134
     * Определеяет, есть ля для результата с именем "from" данные для наложения на transientVars
135
     *
136
     * @param $from
137
     *
138
     * @return boolean
139
     */
140
    public function hasResultMap($from)
141
    {
142
        return array_key_exists($from, $this->resultMap);
143
    }
144
145
146
    /**
147
     * Возвращает данные для маппинга результатов
148
     *
149
     * @param $from
150
     *
151
     * @return ResultMapMetadataInterface
152
     *
153
     * @throws Exception\InvalidResultMapException
154
     */
155
    public function getResultMapByFrom($from)
156
    {
157
        if (!$this->hasResultMap($from)) {
158
            $errMsg = sprintf('Map for key %s not found', $from);
159
            throw new Exception\InvalidResultMapException($errMsg);
160
        }
161
        return $this->resultMap[$from];
162
    }
163
}
164