RegistrationController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 5
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 4 1
A register() 0 9 1
1
<?php
2
3
/**
4
 * This file is part of laravel.su package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
declare(strict_types=1);
10
11
namespace App\Http\Controllers\Auth;
12
13
use App\Models\User;
14
use Illuminate\Contracts\View\View;
15
use App\Http\Controllers\Controller;
16
use Illuminate\Contracts\Auth\Guard;
17
use Illuminate\Http\RedirectResponse;
18
use Illuminate\Contracts\View\Factory;
19
use App\Http\Requests\RegistrationRequest;
20
use Illuminate\Contracts\Auth\StatefulGuard;
21
22
/**
23
 * Class RegistrationController.
24
 */
25
class RegistrationController extends Controller
26
{
27
    /**
28
     * @param  Factory $factory
29
     * @return View
30
     */
31
    public function index(Factory $factory): View
32
    {
33
        return $factory->make('page.auth.registration');
34
    }
35
36
    /**
37
     * @param  RegistrationRequest $request
38
     * @param  Guard               $guard
39
     * @return RedirectResponse
40
     */
41
    public function register(RegistrationRequest $request, Guard $guard): RedirectResponse
42
    {
43
        $user = User::create($request->only('name', 'email', 'password'));
44
45
        /* @var StatefulGuard $guard */
46
        $guard->login($user, true);
47
48
        return redirect()->route('home');
49
    }
50
}
51