Code Duplication    Length = 17-18 lines in 3 locations

src/Palladium/Service/Identification.php 3 locations

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