Issues (15)

src/Middleware/LocaleMiddleware.php (3 issues)

Labels
Severity
1
<?php
2
3
namespace JosephNC\Translation\Middleware;
4
5
use Closure;
6
use Illuminate\Http\Request;
7
use JosephNC\Translation\Facades\Translation;
8
9
class LocaleMiddleware
10
{
11
    /**
12
     * Sets the locale cookie on every request depending
13
     * on the locale supplied in the route prefix.
14
     *
15
     * @param Request $request
16
     * @param Closure $next
17
     *
18
     * @return mixed
19
     */
20
    public function handle(Request $request, Closure $next)
21
    {
22
        $lang = Translation::getRoutePrefix() ?? '';
0 ignored issues
show
The method getRoutePrefix() does not exist on JosephNC\Translation\Facades\Translation. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

22
        $lang = Translation::/** @scrutinizer ignore-call */ getRoutePrefix() ?? '';
Loading history...
23
        $lang = empty( $lang ) ? Translation::getLocale() : $lang;
0 ignored issues
show
The method getLocale() does not exist on JosephNC\Translation\Facades\Translation. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

23
        $lang = empty( $lang ) ? Translation::/** @scrutinizer ignore-call */ getLocale() : $lang;
Loading history...
24
25
        Translation::setLocale( $lang );
0 ignored issues
show
The method setLocale() does not exist on JosephNC\Translation\Facades\Translation. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

25
        Translation::/** @scrutinizer ignore-call */ 
26
                     setLocale( $lang );
Loading history...
26
27
        return $next($request);
28
    }
29
}
30