Passed
Push — master ( 624a9a...4c85b9 )
by Arthur
36:47
created

Module   A

Complexity

Total Complexity 31

Size/Duplication

Total Lines 176
Duplicated Lines 0 %

Test Coverage

Coverage 90.63%

Importance

Changes 0
Metric Value
eloc 35
dl 0
loc 176
ccs 58
cts 64
cp 0.9063
rs 9.92
c 0
b 0
f 0
wmc 31

31 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 3 1
A getFactories() 0 3 1
A getConfigs() 0 3 1
A getAttributes() 0 3 1
A getListeners() 0 3 1
A getPath() 0 3 1
A getCommands() 0 3 1
A getRoutes() 0 3 1
A getMigrations() 0 3 1
A getTests() 0 3 1
A getTransformers() 0 3 1
A getRules() 0 3 1
A getControllers() 0 3 1
A getServiceProviders() 0 3 1
A getServices() 0 3 1
A getMainModel() 0 3 1
A getNamespace() 0 3 1
A getDtos() 0 3 1
A getPolicies() 0 3 1
A exists() 0 3 1
A getSeeders() 0 3 1
A doesNotExist() 0 3 1
A getJobs() 0 3 1
A getEvents() 0 3 1
A getPermissions() 0 3 1
A getNotifications() 0 3 1
A getRequests() 0 3 1
A getMiddleWare() 0 3 1
A getObservers() 0 3 1
A getModels() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 09.03.19
6
 * Time: 21:51.
7
 */
8
9
namespace Foundation\Core;
10
11
use Foundation\Abstracts\Events\Event;
12
use Foundation\Abstracts\Jobs\Job;
13
use Foundation\Abstracts\Listeners\Listener;
14
use Foundation\Abstracts\Middleware\Middleware;
15
use Foundation\Abstracts\Observers\Observer;
16
use Foundation\Abstracts\Policies\Policy;
17
use Foundation\Abstracts\Services\Service;
18
use Illuminate\Console\Command;
19
use Illuminate\Database\Eloquent\Model;
20
use Illuminate\Database\Migrations\Migration;
21
use Illuminate\Database\Seeder;
22
use Illuminate\Foundation\Testing\TestCase;
23
use Illuminate\Http\Request;
24
use Illuminate\Http\Resources\Json\JsonResource;
25
use Illuminate\Notifications\Notification;
26
use Illuminate\Routing\Controller;
27
use Illuminate\Support\ServiceProvider;
28
use Illuminate\Validation\Rule;
29
30
final class Module
31
{
32
    /**
33
     * @var string
34
     */
35
    protected $name;
36
37
    /**
38
     * @var string
39
     */
40
    protected $path;
41
42
    /**
43
     * LarapiModule constructor.
44
     * @param $name
45
     */
46 130
    public function __construct(string $name, string $path)
47
    {
48 130
        $this->name = $name;
49 130
        $this->path = $path;
50 130
    }
51
52
    /**
53
     * @return string
54
     */
55 130
    public function getName(): string
56
    {
57 130
        return $this->name;
58
    }
59
60
    /**
61
     * @return string
62
     */
63 130
    public function getPath(): string
64
    {
65 130
        return $this->path;
66
    }
67
68 2
    public function getListeners()
69
    {
70 2
        return new Resource('listeners', '/Listeners', $this, Listener::class);
71
    }
72
73 130
    public function getConfigs()
74
    {
75 130
        return new Resource('configs', '/Config', $this);
76
    }
77
78 130
    public function getFactories()
79
    {
80 130
        return new Resource('factories', '/Database/factories', $this);
81
    }
82
83 1
    public function getAttributes()
84
    {
85 1
        return new Resource('attributes', '/Attributes', $this);
86
    }
87
88 1
    public function getDtos()
89
    {
90 1
        return new Resource('dtos', '/Dtos', $this);
91
    }
92
93 130
    public function getEvents()
94
    {
95 130
        return new Resource('events', '/Events', $this, Event::class);
96
    }
97
98 130
    public function getRoutes()
99
    {
100 130
        return new Resource('routes', '/Routes', $this);
101
    }
102
103 1
    public function getServices()
104
    {
105 1
        return new Resource('services', '/Services', $this, Service::class);
106
    }
107
108 1
    public function getPolicies()
109
    {
110 1
        return new Resource('policies', '/Policies', $this, Policy::class);
111
    }
112
113 2
    public function getPermissions()
114
    {
115 2
        return new Resource('permissions', '/Permissions', $this);
116
    }
117
118 1
    public function getTransformers()
119
    {
120 1
        return new Resource('transformers', '/Transformers', $this, JsonResource::class);
121
    }
122
123 130
    public function getServiceProviders()
124
    {
125 130
        return new Resource('providers', '/Providers', $this, ServiceProvider::class);
126
    }
127
128 130
    public function getMigrations()
129
    {
130 130
        return new Resource('migrations', '/Database/Migrations', $this, Migration::class);
131
    }
132
133 130
    public function getModels()
134
    {
135 130
        return new Resource('models', '/Entities', $this, Model::class);
136
    }
137
138
    public function getObservers()
139
    {
140
        return new Resource('observers', '/Observers', $this, Observer::class);
141
    }
142
143 130
    public function getSeeders()
144
    {
145 130
        return new Resource('seeders', '/Database/Seeders', $this, Seeder::class);
146
    }
147
148 1
    public function getRequests()
149
    {
150 1
        return new Resource('requests', '/Http/Requests', $this, Request::class);
151
    }
152
153 1
    public function getRules()
154
    {
155 1
        return new Resource('rules', '/Rules', $this, Rule::class);
156
    }
157
158 1
    public function getMiddleWare()
159
    {
160 1
        return new Resource('middleware', '/Http/Middleware', $this, MiddleWare::class);
161
    }
162
163 1
    public function getTests()
164
    {
165 1
        return new Resource('tests', '/Tests', $this, TestCase::class);
166
    }
167
168 130
    public function getCommands()
169
    {
170 130
        return new Resource('commands', '/Console', $this, Command::class);
171
    }
172
173 1
    public function getNotifications()
174
    {
175 1
        return new Resource('notifications', '/Notifications', $this, Notification::class);
176
    }
177
178 130
    public function getControllers()
179
    {
180 130
        return new Resource('controllers', '/Http/Controllers', $this, Controller::class);
181
    }
182
183 2
    public function getJobs()
184
    {
185 2
        return new Resource('jobs', '/Jobs', $this, Job::class);
186
    }
187
188 130
    public function getNamespace(): string
189
    {
190 130
        return 'Modules' . '\\' . $this->getName();
191
    }
192
193 130
    public function getMainModel()
194
    {
195 130
        return $this->getModels()->getClassByName($this->getName());
196
    }
197
198
    public function exists(): bool
199
    {
200
        return file_exists($this->getPath());
201
    }
202
203
    public function doesNotExist()
204
    {
205
        return !$this->exists();
206
    }
207
}
208