Notification::generate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 0
dl 0
loc 20
rs 9.8666
c 0
b 0
f 0
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
    private static $destination = "laragen/app/Notifications";
12
    private static $namespace  = "Laragen\App\Notifications";
13
    private static $template = "backend/notifications/notification";
14
15
    public function generate()
16
    {
17
        $fullFilePaths = [];
18
        $eventsType = config('laragen.options.events');
19
        
20
        foreach ($eventsType as $eventType)
21
        {
22
            $controllerTemplate = $this->buildTemplate(self::$template, [
23
                '{{namespace}}'          => self::$namespace,
24
                '{{modelName}}'          => $this->module->getModelName(),
25
                '{{eventTypeUppercase}}'          => Str::ucfirst($eventType),
26
                '{{eventTypeLowercase}}'          => Str::lower($eventType)
27
            ]);
28
            
29
            $fullFilePath = $this->getPath(self::$destination."/").$this->module->getModelName().Str::ucfirst($eventType)."Notification".".php";
30
            $fullFilePaths[] = $fullFilePath;
31
            file_put_contents($fullFilePath, $controllerTemplate);
32
        }
33
        
34
        return $fullFilePaths;
35
    }
36
37
}
38