BaseModuleServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 3
nc 4
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Contains the BaseModuleServiceProvider class.
7
 *
8
 * @copyright   Copyright (c) 2016 Attila Fulop
9
 * @author      Attila Fulop
10
 * @license     MIT
11
 * @since       2016-08-14
12
 *
13
 */
14
15
namespace Konekt\Concord;
16
17
use Illuminate\Support\ServiceProvider;
18
use Konekt\Concord\Concerns\AutoGeneratesModuleId;
19
use Konekt\Concord\Concerns\HasDefaultConvention;
20
use Konekt\Concord\Concerns\HasModuleConfig;
21
use Konekt\Concord\Concerns\ReadsManifestFile;
22
use Konekt\Concord\Concerns\RegistersEnums;
23
use Konekt\Concord\Concerns\RegistersModels;
24
use Konekt\Concord\Contracts\Concord as ConcordContract;
25
use Konekt\Concord\Contracts\Module;
26
use Konekt\Concord\Module\Kind;
27
use ReflectionClass;
28
29
class BaseModuleServiceProvider extends ServiceProvider implements Module
30
{
31
    use HasModuleConfig;
32
    use AutoGeneratesModuleId;
33
    use HasDefaultConvention;
34
    use RegistersEnums;
35
    use RegistersModels;
36
    use ReadsManifestFile;
37
38
    private string $basePath;
39
40
    public function __construct($app)
41
    {
42
        parent::__construct($app);
43
44
        $this->concord = $app->make(ConcordContract::class);
45
        $this->basePath = dirname(dirname((new ReflectionClass(static::class))->getFileName()));
46
    }
47
48
    public function boot()
49
    {
50
        if ($this->areMigrationsEnabled()) {
51
            //$this->registerMigrations();
52
        }
53
54
        if ($this->areModelsEnabled()) {
55
            $this->registerModels();
56
            $this->registerEnums();
57
            //$this->registerRequestTypes();
58
        }
59
    }
60
61
    public function getName(): string
62
    {
63
        return $this->manifest(static::getConvention())->getName();
64
    }
65
66
    public function getVersion(): ?string
67
    {
68
        return $this->manifest(static::getConvention())->getVersion();
69
    }
70
71
    public function getBasePath(): string
72
    {
73
        return $this->basePath;
74
    }
75
76
    public function getNamespaceRoot(): string
77
    {
78
        return '';
79
    }
80
81
    public function getKind(): Kind
82
    {
83
        return Kind::MODULE();
0 ignored issues
show
Bug introduced by
The method MODULE() does not exist on Konekt\Concord\Module\Kind. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

83
        return Kind::/** @scrutinizer ignore-call */ MODULE();
Loading history...
84
    }
85
86
    public function shortName()
87
    {
88
        return '';
89
    }
90
}
91