Passed
Push — master ( 40ce26...965fb6 )
by Arthur
22:04
created

DefaultModuleGenerator::generate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 37
rs 9.568
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 23.03.19
6
 * Time: 00:51
7
 */
8
9
namespace Foundation\Generator\Generators;
10
11
12
use Foundation\Generator\Factories\ModuleFactory;
13
14
/**
15
 * Class DefaultModuleGenerator
16
 * @package Foundation\Generator\Generators
17
 */
18
class DefaultModuleGenerator
19
{
20
    /**
21
     * @var string
22
     */
23
    protected $moduleName;
24
25
    /**
26
     * @var ModuleFactory
27
     */
28
    protected $moduleFactory;
29
30
    /**
31
     * DefaultModuleGenerator constructor.
32
     * @param $moduleFactory
33
     */
34
    public function __construct(string $moduleName)
35
    {
36
        $this->moduleName = $moduleName;
37
        $this->moduleFactory = new ModuleFactory($moduleName);
38
    }
39
40
    /**
41
     *
42
     */
43
    public function generate(){
44
45
        $this->moduleFactory->addModel($this->moduleName, true, true);
46
47
        $this->moduleFactory->addService($this->moduleName . 'Service');
48
49
        $this->moduleFactory->addController($this->moduleName . "Controller");
50
51
        $this->moduleFactory->addTest($this->moduleName . 'ServiceTest', 'service');
52
        $this->moduleFactory->addTest($this->moduleName . 'HttpTest', 'http');
53
        $this->moduleFactory->addTest($this->moduleName . 'UnitTest', 'unit');
54
55
        $this->moduleFactory->addEvent($this->moduleName . 'WasCreatedEvent');
56
        $this->moduleFactory->addEvent($this->moduleName . 'WasUpdatedEvent');
57
        $this->moduleFactory->addEvent($this->moduleName . 'WasDeletedEvent');
58
59
        $this->moduleFactory->addRequest('Find'.$this->moduleName . 'Request');
60
        $this->moduleFactory->addRequest('Index'.$this->moduleName . 'Request');
61
        $this->moduleFactory->addRequest('Create'.$this->moduleName . 'Request');
62
        $this->moduleFactory->addRequest('Update'.$this->moduleName . 'Request');
63
        $this->moduleFactory->addRequest('Delete'.$this->moduleName . 'Request');
64
65
        $this->moduleFactory->addPermission($this->moduleName . 'Permission');
66
67
        $this->moduleFactory->addPolicy($this->moduleName . 'Policy');
68
69
        $this->moduleFactory->addFactory($this->moduleName);
70
71
        $this->moduleFactory->addTransformer($this->moduleName.'Transformer', $this->moduleName);
72
73
        $this->moduleFactory->addServiceProvider($this->moduleName . 'ServiceProvider');
74
75
        $this->moduleFactory->addRoute();
76
77
        $this->moduleFactory->addComposer();
78
79
        $this->moduleFactory->build();
80
    }
81
82
83
}
84