Passed
Push — master ( 502cab...a00bcc )
by Greg
05:16
created

PasswordRequestForm::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 9
rs 10
1
<?php
2
/**
3
 * webtrees: online genealogy
4
 * Copyright (C) 2019 webtrees development team
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
 * GNU General Public License for more details.
13
 * You should have received a copy of the GNU General Public License
14
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15
 */
16
declare(strict_types=1);
17
18
namespace Fisharebest\Webtrees\Http\RequestHandlers;
19
20
use Fisharebest\Webtrees\Auth;
21
use Fisharebest\Webtrees\Http\ViewResponseTrait;
22
use Fisharebest\Webtrees\I18N;
23
use Psr\Http\Message\ResponseInterface;
24
use Psr\Http\Message\ServerRequestInterface;
25
use Psr\Http\Server\RequestHandlerInterface;
26
use function redirect;
27
use function route;
28
29
/**
30
 * Request a new password.
31
 */
32
class PasswordRequestForm implements RequestHandlerInterface
33
{
34
    use ViewResponseTrait;
35
36
    /**
37
     * @param ServerRequestInterface $request
38
     *
39
     * @return ResponseInterface
40
     */
41
    public function handle(ServerRequestInterface $request): ResponseInterface
42
    {
43
        if (Auth::check()) {
44
            return redirect(route('user-page'));
45
        }
46
47
        $title = I18N::translate('Request a new password');
48
49
        return $this->viewResponse('password-request-page', ['title' => $title]);
50
    }
51
}
52