Issues (94)

src/Traits/ConfigTrait.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace FaithGen\SDK\Traits;
4
5
use Illuminate\Support\Facades\Route;
6
7
trait ConfigTrait
8
{
9
    /**
10
     * The config you want to be applied onto your routes.
11
     * @return array the rules eg, middleware, prefix, namespace
12
     */
13
    abstract public function routeConfiguration(): array;
14
15
    /**
16
     * This configures the routes with the given routes.
17
     * @param string|array $primaryRoute the primary route(s) files to be loaded whatsoever
18
     * @param string|array $secondaryRoute the route(s) files to be loaded when in source mode
19
     */
20
    protected function registerRoutes($primaryRoute, $secondaryRoute)
21
    {
22
        Route::group($this->routeConfiguration(), function () use ($primaryRoute, $secondaryRoute) {
23
            $this->loadRoutes($primaryRoute);
24
            if (config('faithgen-sdk.source')) {
25
                $this->loadRoutes($secondaryRoute);
26
            }
27
        });
28
    }
29
30
    private function loadRoutes($routes)
31
    {
32
        if ($routes) {
33
            if (is_string($routes)) {
34
                $this->loadRoutesFrom($routes);
0 ignored issues
show
The method loadRoutesFrom() does not exist on FaithGen\SDK\Traits\ConfigTrait. Did you maybe mean loadRoutes()? ( Ignorable by Annotation )

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

34
                $this->/** @scrutinizer ignore-call */ 
35
                       loadRoutesFrom($routes);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
35
            } elseif (is_array($routes)) {
36
                foreach ($routes as $route) {
37
                    $this->loadRoutesFrom($route);
38
                }
39
            }
40
        }
41
    }
42
43
    /*
44
     * Sets up the migrations, views and every other files you want to publish
45
     */
46
    protected function setUpSourceFiles(\Closure $closure)
47
    {
48
        if ($this->app->runningInConsole()) {
49
            if (config('faithgen-sdk.source')) {
50
                $closure->call($this);
51
            }
52
        }
53
    }
54
}
55