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

FactoriesLoader::getFilesPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LaravelModulize\Services\Loaders;
4
5
use Illuminate\Support\Collection;
6
use LaravelModulize\Contracts\LoadsFiles;
7
use Illuminate\Contracts\Foundation\Application;
8
use LaravelModulize\Contracts\ModulizerRepositoryInterface;
9
10
class FactoriesLoader extends BaseFileLoader implements LoadsFiles
11
{
12
    /**
13
     * Load the files to load and register them
14
     *
15
     * @param string $module
16
     * @return void
17
     */
18
    public function loadFiles(string $module): void
19
    {
20
        if (!$this->getFilesToLoad($module)->isEmpty()) {
21
            $this->repo->registerEloquentFactoriesFrom($this->getFilesPath());
0 ignored issues
show
Bug introduced by
The method registerEloquentFactoriesFrom() 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

21
            $this->repo->/** @scrutinizer ignore-call */ 
22
                         registerEloquentFactoriesFrom($this->getFilesPath());
Loading history...
Bug introduced by
The call to LaravelModulize\Services...sLoader::getFilesPath() has too few arguments starting with module. ( Ignorable by Annotation )

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

21
            $this->repo->registerEloquentFactoriesFrom($this->/** @scrutinizer ignore-call */ getFilesPath());

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
22
        }
23
    }
24
25
    /**
26
     * Retrieve the path where the files to load should be at
27
     *
28
     * @param string $module
29
     * @return string
30
     */
31
    public function getFilesPath(string $module): string
32
    {
33
        return $this->repo->getModulePath($module) . "/database/factories";
34
    }
35
36
    /**
37
     * Retrieve the namespace to be used when registering the files
38
     *
39
     * @param string $module
40
     * @return string
41
     */
42
    public function getNamespace(string $module): string
43
    {
44
        return $this->repo
45
            ->getModuleNamespace($module);
46
    }
47
48
}
49