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.
Completed
Push — master ( bc496a...73ae4f )
by Андрей
03:11
created

Metadata   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 190
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
c 1
b 0
f 0
lcom 2
cbo 3
dl 0
loc 190
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A addArgumentMap() 0 11 2
A getArgumentsMap() 0 4 1
A getResultVariableName() 0 4 1
A setResultVariableName() 0 6 1
A isAllowOverrideResult() 0 4 1
A setAllowOverrideResult() 0 6 1
A getFlagUseResultMap() 0 4 1
A addResultMap() 0 15 2
A hasResultMap() 0 4 1
A getResultMapByFrom() 0 8 2
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
     * Карта маппинга документов
17
     *
18
     * @var array
19
     */
20
    protected $argumentsMap = [];
21
22
    /**
23
     * Имя переменной в transientVars, в которую нужно сохранить результаты сервиса
24
     *
25
     * @var string|null
26
     */
27
    protected $resultVariableName;
28
29
    /**
30
     * Определяет можно ли перетирать уже существующую переменную
31
     *
32
     * @var bool
33
     */
34
    protected $allowOverrideResult = false;
35
36
    /**
37
     * Флаг определяет используется ли маппинг результатов
38
     *
39
     * @var bool
40
     */
41
    protected $flagUseResultMap = false;
42
43
    /**
44
     * Карта для наложения результатов работы сервиса в TransientVars
45
     *
46
     * @var array
47
     */
48
    protected $resultMap = [];
49
50
    /**
51
     * Хеши обеспечивающие уникальность данных используемых для маппинга результатов работы сервиса
52
     *
53
     * @var array
54
     */
55
    protected $resultMapHash = [];
56
57
    /**
58
     * Добвляет элемент в карту маппинга аргументов
59
     *
60
     * @param $to
61
     * @param $fromArgName
62
     *
63
     * @return $this
64
     *
65
     * @throws Exception\InvalidArgumentMapException
66
     */
67
    public function addArgumentMap($to, $fromArgName)
68
    {
69
        if (array_key_exists($to, $this->argumentsMap)) {
70
            $errMsg = sprintf('Map for argument "%s" already exists', $to);
71
            throw new Exception\InvalidArgumentMapException($errMsg);
72
        }
73
74
        $this->argumentsMap[$to] = $fromArgName;
75
76
        return $this;
77
    }
78
79
    /**
80
     * Возвращает карту маппинга документов
81
     *
82
     * @return array
83
     */
84
    public function getArgumentsMap()
85
    {
86
        return $this->argumentsMap;
87
    }
88
89
    /**
90
     * Имя переменной в transientVars, в которую нужно сохранить результаты сервиса
91
     *
92
     * @return string|null
93
     */
94
    public function getResultVariableName()
95
    {
96
        return $this->resultVariableName;
97
    }
98
99
    /**
100
     * Устанавливает имя переменной в transientVars, в которую нужно сохранить результаты сервиса
101
     *
102
     * @param string $resultVariableName
103
     *
104
     * @return $this
105
     */
106
    public function setResultVariableName($resultVariableName)
107
    {
108
        $this->resultVariableName = (string)$resultVariableName;
109
110
        return $this;
111
    }
112
113
    /**
114
     * Определяет можно ли перетирать уже существующую переменную
115
     *
116
     * @return boolean
117
     */
118
    public function isAllowOverrideResult()
119
    {
120
        return $this->allowOverrideResult;
121
    }
122
123
    /**
124
     * Определяет можно ли перетирать уже существующую переменную
125
     *
126
     * @param boolean $allowOverrideResult
127
     *
128
     * @return $this
129
     */
130
    public function setAllowOverrideResult($allowOverrideResult)
131
    {
132
        $this->allowOverrideResult = (boolean)$allowOverrideResult;
133
134
        return $this;
135
    }
136
137
    /**
138
     * Флаг определяет используется ли маппинг результатов
139
     *
140
     * @return boolean
141
     */
142
    public function getFlagUseResultMap()
143
    {
144
        return $this->flagUseResultMap;
145
    }
146
147
    /**
148
     * Добавляет информацию о маппинге результатов работы функции
149
     *
150
     * @param ResultMapMetadataInterface $item
151
     *
152
     * @return $this
153
     *
154
     * @throws Exception\InvalidResultMapException
155
     */
156
    public function addResultMap(ResultMapMetadataInterface $item)
157
    {
158
        $key = $item->getFrom() . '_' . $item->getTo();
159
        if (array_key_exists($key, $this->resultMapHash)) {
160
            $errMsg = sprintf('Map for key %s already exists', $key);
161
            throw new Exception\InvalidResultMapException($errMsg);
162
        }
163
164
165
        $this->resultMap[$item->getFrom()] = $item;
166
        $this->resultMapHash[$key] = $key;
167
        $this->flagUseResultMap = true;
168
169
        return $this;
170
    }
171
172
    /**
173
     * Определеяет, есть ля для результата с именем "from" данные для наложения на transientVars
174
     *
175
     * @param $from
176
     *
177
     * @return boolean
178
     */
179
    public function hasResultMap($from)
180
    {
181
        return array_key_exists($from, $this->resultMap);
182
    }
183
184
185
    /**
186
     * Возвращает данные для маппинга результатов
187
     *
188
     * @param $from
189
     *
190
     * @return ResultMapMetadataInterface
191
     *
192
     * @throws Exception\InvalidResultMapException
193
     */
194
    public function getResultMapByFrom($from)
195
    {
196
        if (!$this->hasResultMap($from)) {
197
            $errMsg = sprintf('Map for key %s not found', $from);
198
            throw new Exception\InvalidResultMapException($errMsg);
199
        }
200
        return $this->resultMap[$from];
201
    }
202
}
203