Passed
Branch master (d88b3b)
by Prateek
03:56
created

Notification::generate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 11
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 19
rs 9.9
1
<?php
2
namespace Prateekkarki\Laragen\Generators\Backend;
3
4
use Prateekkarki\Laragen\Generators\BaseGenerator;
5
use Prateekkarki\Laragen\Generators\GeneratorInterface;
6
7
use Illuminate\Support\Str;
8
9
class Notification extends BaseGenerator implements GeneratorInterface
10
{
11
    public function generate()
12
    {
13
        $fullFilePaths = [];
14
        $eventsType = config('laragen.options.events');
15
        
16
        foreach ($eventsType as $eventType)
17
        {
18
            $controllerTemplate = $this->buildTemplate('backend/notifications/notification', [
19
                '{{modelName}}'          => $this->module->getModelName(),
20
                '{{eventTypeUppercase}}'          => Str::ucfirst($eventType),
21
                '{{eventTypeLowercase}}'          => Str::lower($eventType)
22
            ]);
23
            
24
            $fullFilePath = $this->getPath("app/Notifications/").$this->module->getModelName().Str::ucfirst($eventType)."Notification".".php";
25
            $fullFilePaths[] = $fullFilePath;
26
            file_put_contents($fullFilePath, $controllerTemplate);
27
        }
28
        
29
        return $fullFilePaths;
30
    }
31
32
}
33