TestAuthController::auth()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 11
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 18
rs 9.9
1
<?php
2
3
declare(strict_types=1);
4
5
namespace KielD01\LaravelMaterialDashboardPro\Http\Controllers;
6
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Http\Request;
9
use Illuminate\Routing\Controller;
10
use Illuminate\Support\Str;
11
12
class TestAuthController extends Controller
13
{
14
    public function login(): string
15
    {
16
        return view('mdp::pages.user.login')->render();
17
    }
18
19
    public function auth(Request $request): RedirectResponse
20
    {
21
        $credentials = [
22
            'email' => $request->post('email'),
23
            'password' => $request->post('password')
24
        ];
25
26
        $emailCheck = Str::is('[email protected]', $credentials['email']);
0 ignored issues
show
Bug introduced by
It seems like $credentials['email'] can also be of type array; however, parameter $value of Illuminate\Support\Str::is() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $emailCheck = Str::is('[email protected]', /** @scrutinizer ignore-type */ $credentials['email']);
Loading history...
27
        $passwordCheck = Str::is('adminTest!123', $credentials['password']);
28
        $checksPassed = $emailCheck && $passwordCheck;
29
30
        if ($checksPassed) {
31
            return redirect(route('kield01.mdp.dashboard.index'));
32
        }
33
34
        return redirect()
35
            ->back()
36
            ->with($credentials);
37
    }
38
39
    public function register(): string
40
    {
41
        return view('mdp::pages.user.register')->render();
42
    }
43
}
44