EnvironmentSetUp::getEnvironmentSetUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
c 2
b 0
f 0
dl 0
loc 12
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CaribouFute\LocaleRoute\TestHelpers;
4
5
use CaribouFute\LocaleRoute\Middleware\SetSessionLocale;
6
use CaribouFute\LocaleRoute\Prefix\Route as PrefixRoute;
7
use CaribouFute\LocaleRoute\Routing\LocaleRouter;
8
use Illuminate\Support\Facades\Route;
9
10
trait EnvironmentSetUp
11
{
12
    protected $locales;
13
    protected $addLocaleToUrl;
14
15
    protected function getEnvironmentSetUp($app)
16
    {
17
        $this->locales = ['fr', 'en'];
18
        $this->addLocaleToUrl = true;
19
20
        $app['config']->set('localeroute.locales', $this->locales);
21
        $app['config']->set('localeroute.add_locale_to_url', $this->addLocaleToUrl);
22
23
        $app['locale-route'] = app()->make(LocaleRouter::class);
24
        $app['locale-route-url'] = app()->make(PrefixRoute::class);
25
26
        $app['router']->aliasMiddleware('locale.session', SetSessionLocale::class);
27
    }
28
29
    public function getRouteInfo()
30
    {
31
        $routeColl = collect(Route::getRoutes()->getRoutes());
0 ignored issues
show
Bug introduced by
Illuminate\Support\Facad...etRoutes()->getRoutes() of type Illuminate\Routing\Route[] is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $value of collect(). ( Ignorable by Annotation )

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

31
        $routeColl = collect(/** @scrutinizer ignore-type */ Route::getRoutes()->getRoutes());
Loading history...
32
        $routeInfo = $routeColl->map(function ($route) {
33
            return [
34
                'methods' => $route->methods(),
35
                'name' => $route->getName(),
36
                'uri' => $route->uri(),
37
            ];
38
        });
39
40
        return $routeInfo;
41
    }
42
43
    public function ddRouteInfo()
44
    {
45
        dd($this->getRouteInfo());
46
    }
47
}
48