LocaleController::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace BBSLab\NovaTranslation\Http\Controllers;
4
5
use BBSLab\NovaTranslation\Models\Locale;
6
use BBSLab\NovaTranslation\NovaTranslation;
7
use Illuminate\Http\Request;
8
9
class LocaleController
10
{
11
    public function __invoke(Request $request, string $locale)
12
    {
13
        if (Locale::query()->where('iso', '=', $locale)->exists()) {
0 ignored issues
show
Bug introduced by
The method exists() does not exist on Illuminate\Database\Eloquent\Builder. Did you maybe mean canUseExistsForExistenceCheck()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
14
            $request->session()->put(
0 ignored issues
show
Bug introduced by
The method put cannot be called on $request->session() (of type callable).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
15
                NovaTranslation::localeSessionKey(),
16
                $locale
17
            );
18
        }
19
20
        return redirect()->back();
21
    }
22
}
23