LocaleInFirstSegment   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 3 1
A get() 0 3 1
1
<?php
2
3
namespace mindtwo\LaravelMultilingual\Http\Middleware\LocaleDetectors;
4
5
use Illuminate\Http\Request;
6
use mindtwo\LaravelMultilingual\Services\Locale;
7
8
class LocaleInFirstSegment implements LocaleDetector
9
{
10
    /**
11
     * @param Request $request
12
     * @param Locale  $locale
13
     *
14
     * @return bool
15
     */
16
    public function match(Request $request, Locale $locale): bool
17
    {
18
        return $locale->available->contains(collect($request->segments())->first());
0 ignored issues
show
Bug Best Practice introduced by
The property available does not exist on mindtwo\LaravelMultilingual\Services\Locale. Since you implemented __get, consider adding a @property annotation.
Loading history...
19
    }
20
21
    /**
22
     * @param Request $request
23
     * @param Locale  $locale
24
     *
25
     * @return string
26
     */
27
    public function get(Request $request, Locale $locale): string
28
    {
29
        return collect($request->segments())->first();
30
    }
31
}
32