Code Duplication    Length = 16-20 lines in 2 locations

src/Guard.php 2 locations

@@ 89-108 (lines=20) @@
86
     *
87
     * @return \Lcobucci\JWT\Token
88
     */
89
    protected function getTokenForRequest()
90
    {
91
        $token = $this->request->bearerToken();
92
93
        if (empty($token)) {
94
            return null;
95
        }
96
97
        try {
98
            $token = (new Parser())->parse($token);
99
100
            if (!$this->signer->verify($token)) {
101
                return null;
102
            }
103
        } catch (InvalidArgumentException $e) {
104
            return null;
105
        }
106
107
        return $token;
108
    }
109
110
    /**
111
     * Validate a user's credentials.
@@ 158-173 (lines=16) @@
155
    /**
156
     * @return bool
157
     */
158
    public function logout()
159
    {
160
        $token = $this->request->bearerToken();
161
162
        if (empty($token)) {
163
            return true;
164
        }
165
166
        try {
167
            $token = (new Parser())->parse($token);
168
        } catch (InvalidArgumentException $e) {
169
            return false;
170
        }
171
172
        return $this->blacklist->add($token);
173
    }
174
175
    /**
176
     * Set the current request instance.