Passed
Push — master ( 139939...b4b8e8 )
by Arthur
21:54 queued 17s
created

Module::getServices()   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 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\Listeners\Listener;
13
use Foundation\Abstracts\Middleware\Middleware;
14
use Foundation\Abstracts\Observers\Observer;
15
use Foundation\Abstracts\Policies\Policy;
16
use Foundation\Abstracts\Services\Service;
17
use Illuminate\Console\Command;
18
use Illuminate\Database\Eloquent\Model;
19
use Illuminate\Database\Migrations\Migration;
20
use Illuminate\Database\Seeder;
21
use Illuminate\Foundation\Testing\TestCase;
22
use Illuminate\Http\Request;
23
use Illuminate\Http\Resources\Json\JsonResource;
24
use Illuminate\Notifications\Notification;
25
use Illuminate\Routing\Controller;
26
use Illuminate\Support\ServiceProvider;
27
28
final class Module
29
{
30
    /**
31
     * @var string
32
     */
33
    protected $name;
34
35
    /**
36
     * @var string
37
     */
38
    protected $path;
39
40
    /**
41
     * LarapiModule constructor.
42
     * @param $name
43
     */
44
    public function __construct(string $name, string $path)
45
    {
46
        $this->name = $name;
47
        $this->path = $path;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getName(): string
54
    {
55
        return $this->name;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getPath(): string
62
    {
63
        return $this->path;
64
    }
65
66
67
    public function getListeners()
68
    {
69
        return new Resource('listeners', '/Listeners', $this, Listener::class);
70
    }
71
72
    public function getConfigs()
73
    {
74
        return new Resource('configs', '/Config', $this);
75
    }
76
77
    public function getFactories()
78
    {
79
        return new Resource('factories', '/Database/factories', $this);
80
    }
81
82
    public function getEvents()
83
    {
84
        return new Resource('events', '/Events', $this, Event::class);
85
    }
86
87
    public function getRoutes()
88
    {
89
        return new Resource('routes', '/Routes', $this);
90
    }
91
92
    public function getServices()
93
    {
94
        return new Resource('services', '/Services', $this, Service::class);
95
    }
96
97
    public function getPolicies()
98
    {
99
        return new Resource('policies', '/Policies', $this, Policy::class);
100
    }
101
102
    public function getTransformers()
103
    {
104
        return new Resource('transformers', '/Transformers', $this, JsonResource::class);
105
    }
106
107
    public function getServiceProviders()
108
    {
109
        return new Resource('providers', '/Providers', $this, ServiceProvider::class);
110
    }
111
112
    public function getMigrations()
113
    {
114
        return new Resource('migrations', '/Database/Migrations', $this, Migration::class);
115
    }
116
117
    public function getModels()
118
    {
119
        return new Resource('models', '/Entities', $this, Model::class);
120
    }
121
122
    public function getObservers()
123
    {
124
        return new Resource('observers', '/Observers', $this, Observer::class);
125
    }
126
127
    public function getSeeders()
128
    {
129
        return new Resource('seeders', '/Database/Seeders', $this, Seeder::class);
130
    }
131
132
    public function getRequests()
133
    {
134
        return new Resource('requests', '/Http/Requests', $this, Request::class);
135
    }
136
137
    public function getMiddleWare()
138
    {
139
        return new Resource('middleware', '/Http/Middleware', $this, MiddleWare::class);
140
    }
141
142
    public function getTests()
143
    {
144
        return new Resource('tests', '/Tests', $this, TestCase::class);
145
    }
146
147
    public function getCommands()
148
    {
149
        return new Resource('commands', '/Console', $this, Command::class);
150
    }
151
152
    public function getNotifications()
153
    {
154
        return new Resource('notifications', '/Notifications', $this, Notification::class);
155
    }
156
157
    public function getControllers()
158
    {
159
        return new Resource('controllers', '/Http/Controllers', $this, Controller::class);
160
    }
161
162
    public function getNamespace(): string
163
    {
164
        return 'Modules' . '\\' . $this->getName();
165
    }
166
167
    public function getMainModel()
168
    {
169
        return $this->getModels()->getClassByName($this->getName());
170
    }
171
}
172