Completed
Push — master ( 4d49f2...b9481e )
by Prateek
05:48 queued 03:41
created

BaseGenerator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setModule() 0 3 1
A getTabs() 0 7 2
A getModule() 0 3 1
A buildTemplate() 0 3 1
A getStub() 0 3 1
1
<?php
2
3
namespace Prateekkarki\Laragen\Generators;
4
use Prateekkarki\Laragen\Models\Module;
5
6
7
class BaseGenerator
8
{	
9
	protected $module;
10
11
    public function getModule()
12
    {
13
        return $this->module;
14
    }
15
16
    public function setModule(Module $module)
17
    {
18
        $this->module = $module;
19
    }
20
21
    public function getStub($type)
22
    {
23
        return file_get_contents(__DIR__ . "/../resources/stubs/" . $type . ".stub");
24
    }
25
26
    public function buildTemplate($stub, $variables)
27
    {
28
        return str_replace(array_keys($variables), array_values($variables), $this->getStub($stub));
29
    }
30
31
    public function getTabs($number)
32
    {
33
        $schema = "";
34
        for ($i=0; $i < $number; $i++) { 
35
            $schema .= "    ";
36
        }
37
        return $schema;
38
    }
39
}
40