Completed
Push — master ( aee3a6...824acf )
by Ben
23:56
created

src/Detectors/SegmentDetector.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Thinktomorrow\Locale\Detectors;
4
5
use Illuminate\Http\Request;
6
use Thinktomorrow\Locale\Scope;
7
use Thinktomorrow\Locale\Values\Config;
8
use Thinktomorrow\Locale\Values\Locale;
9
10
class SegmentDetector implements Detector
11
{
12
    /**
13
     * @var Request
14
     */
15
    private $request;
16
17 67
    public function __construct(Request $request)
0 ignored issues
show
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
18
    {
19 67
        $this->request = $request;
20 67
    }
21
22 67
    public function get(Scope $scope, Config $config): ?Locale
23
    {
24 67
        $segment = $this->request->segment(1);
25
26 67
        return $scope->findLocale($segment);
27
    }
28
}
29