Code Duplication    Length = 17-18 lines in 3 locations

src/Palladium/Service/Identification.php 3 locations

@@ 139-155 (lines=17) @@
136
137
        $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class);
138
139
        if ($identity->getExpiresOn() <  time()) {
140
            $identity->setStatus(Entity\Identity::STATUS_EXPIRED);
141
            $mapper->store($identity);
142
            $this->logger->info('cookie expired', [
143
                'input' => [
144
                    'user' => $userId,
145
                    'series' => $series,
146
                    'key' => $key,
147
                ],
148
                'account' => [
149
                    'user' => $identity->getUserId(),
150
                    'identity' => $identity->getId(),
151
                ],
152
            ]);
153
154
            throw new IdentityExpired;
155
        }
156
157
        if ($identity->matchKey($key) === false) {
158
            $identity->setStatus(Entity\Identity::STATUS_BLOCKED);
@@ 157-174 (lines=18) @@
154
            throw new IdentityExpired;
155
        }
156
157
        if ($identity->matchKey($key) === false) {
158
            $identity->setStatus(Entity\Identity::STATUS_BLOCKED);
159
            $mapper->store($identity);
160
161
            $this->logger->error('compromised cookie', [
162
                'input' => [
163
                    'user' => $userId,
164
                    'series' => $series,
165
                    'key' => $key,
166
                ],
167
                'account' => [
168
                    'user' => $identity->getUserId(),
169
                    'identity' => $identity->getId(),
170
                ],
171
            ]);
172
173
            throw new CompromisedCookie;
174
        }
175
176
        $identity->generateNewKey();
177
        $identity->setLastUsed(time());
@@ 230-247 (lines=18) @@
227
228
        $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class);
229
230
        if ($identity->matchKey($key) === false) {
231
            $identity->setStatus(Entity\Identity::STATUS_BLOCKED);
232
            $mapper->store($identity);
233
234
            $this->logger->error('compromised cookie', [
235
                'input' => [
236
                    'user' => $userId,
237
                    'series' => $series,
238
                    'key' => $key,
239
                ],
240
                'account' => [
241
                    'user' => $identity->getUserId(),
242
                    'identity' => $identity->getId(),
243
                ],
244
            ]);
245
246
            throw new CompromisedCookie;
247
        }
248
249
        $identity->setStatus(Entity\Identity::STATUS_DISCARDED);
250
        $mapper->store($identity);