Passed
Push — master ( 762407...a7439c )
by Roy
04:51 queued 03:09
created

BaseFileLoader::bootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LaravelModulize\Services\Loaders;
4
5
use Illuminate\Support\Collection;
6
use Illuminate\Contracts\Foundation\Application;
7
use LaravelModulize\Contracts\ModulizerRepositoryInterface;
8
9
abstract class BaseFileLoader
10
{
11
    /**
12
     * Instance of Application
13
     *
14
     * @var \Illuminate\Contracts\Foundation\Application $app
15
     */
16
    protected $app;
17
18
    /**
19
     * Instance of the repository
20
     *
21
     * @var \LaravelModulize\Contracts\ModulizerRepositoryInterface
22
     */
23
    protected $repo;
24
25
    /**
26
     * Construct the RoutesLoader
27
     *
28
     * @param \LaravelModulize\Contracts\ModulizerRepositoryInterface $repository
29
     * @param \Illuminate\Contracts\Foundation\Application $app
30
     */
31
    public function __construct(ModulizerRepositoryInterface $repository, Application $app)
32
    {
33
        $this->app = $app;
34
        $this->repo = $repository;
35
    }
36
37
    /**
38
     * Go through each of the module and load the necesary files
39
     *
40
     * @return void
41
     */
42
    public function bootstrap(): void
43
    {
44
        $this->repo->getModules()->each(function ($module) {
45
            $this->loadFiles($module);
0 ignored issues
show
Bug introduced by
The method loadFiles() does not exist on LaravelModulize\Services\Loaders\BaseFileLoader. Since it exists in all sub-types, consider adding an abstract or default implementation to LaravelModulize\Services\Loaders\BaseFileLoader. ( Ignorable by Annotation )

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

45
            $this->/** @scrutinizer ignore-call */ 
46
                   loadFiles($module);
Loading history...
46
        });
47
    }
48
49
    /**
50
     * Retrieve the collection of files found for the given module
51
     *
52
     * @param string $module
53
     * @return \Illuminate\Support\Collection
54
     */
55
    public function getFilesToLoad(string $module): Collection
56
    {
57
        if (!$this->repo->filesExist($this->getFilesPath($module))) {
0 ignored issues
show
Bug introduced by
The method getFilesPath() does not exist on LaravelModulize\Services\Loaders\BaseFileLoader. Did you maybe mean getFilesToLoad()? ( Ignorable by Annotation )

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

57
        if (!$this->repo->filesExist($this->/** @scrutinizer ignore-call */ getFilesPath($module))) {

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...
Bug introduced by
The method filesExist() does not exist on LaravelModulize\Contract...izerRepositoryInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to LaravelModulize\Contract...izerRepositoryInterface. ( Ignorable by Annotation )

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

57
        if (!$this->repo->/** @scrutinizer ignore-call */ filesExist($this->getFilesPath($module))) {
Loading history...
58
            return new Collection();
59
        }
60
61
        return $this->repo->getFiles(
62
            $this->getFilesPath($module)
63
        );
64
    }
65
}
66