Issues (7)

src/LaravelReposServiceProvider.php (6 issues)

1
<?php
2
3
4
namespace Zebrainsteam\LaravelRepos;
5
6
use Illuminate\Support\Facades\App;
7
use Illuminate\Support\ServiceProvider;
8
use Repositories\Core\Contracts\ResolverInterface;
9
use Repositories\Core\RepositoryFactory;
10
use Repositories\Core\Resolvers\ChainResolver;
11
use Repositories\Core\Resolvers\ContainerAwareResolver;
12
use Zebrainsteam\LaravelRepos\Console\RepositoryInterfaceMakeCommand;
13
use Zebrainsteam\LaravelRepos\Console\RepositoryMakeCommand;
14
15
class LaravelReposServiceProvider extends ServiceProvider
16
{
17
    public function boot()
18
    {
19
        if ($this->app->runningInConsole()) {
0 ignored issues
show
The method runningInConsole() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

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

19
        if ($this->app->/** @scrutinizer ignore-call */ runningInConsole()) {

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...
20
            $this->commands([
0 ignored issues
show
The method commands() does not exist on Zebrainsteam\LaravelRepo...velReposServiceProvider. ( Ignorable by Annotation )

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

20
            $this->/** @scrutinizer ignore-call */ 
21
                   commands([

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...
21
                RepositoryInterfaceMakeCommand::class,
22
                RepositoryMakeCommand::class,
23
            ]);
24
        }
25
26
        $this->publishes([
0 ignored issues
show
The method publishes() does not exist on Zebrainsteam\LaravelRepo...velReposServiceProvider. ( Ignorable by Annotation )

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

26
        $this->/** @scrutinizer ignore-call */ 
27
               publishes([

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...
27
            __DIR__.'/config/repositories.php' => config_path('repositories.php'),
28
        ]);
29
    }
30
31
    public function register()
32
    {
33
        $this->app->singleton(ContainerAwareResolver::class, function ($app) {
0 ignored issues
show
The method singleton() does not exist on Tests\Laravel\App. ( Ignorable by Annotation )

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

33
        $this->app->/** @scrutinizer ignore-call */ 
34
                    singleton(ContainerAwareResolver::class, function ($app) {

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...
34
            return new ContainerAwareResolver($app);
35
        });
36
37
        if (empty(config('repositories.resolvers'))
38
            || empty(config('repositories.bindings'))
39
        ) {
40
            throw new \Exception('Invalid repository config');
41
        }
42
43
        $this->app->singleton(RepositoryFactory::class, function ($app) {
0 ignored issues
show
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

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

43
        $this->app->singleton(RepositoryFactory::class, function (/** @scrutinizer ignore-unused */ $app) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
44
            foreach (config('repositories.resolvers') as $resolverClass) {
45
                $resolver = App::get($resolverClass);
46
47
                if ($resolver instanceof ResolverInterface) {
48
                    $resolvers[] = $resolver;
49
                } else {
50
                    throw new \Exception('Invalid resolver class ' . $resolverClass);
51
                }
52
            }
53
54
            $resolver = new ChainResolver($resolvers);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $resolvers seems to be defined by a foreach iteration on line 44. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
55
56
            return new RepositoryFactory($resolver, config('repositories.bindings'));
57
        });
58
    }
59
}
60