Passed
Push — master ( 9de3df...49c81a )
by Richard
11:22 queued 11s
created

get_artomator_template_file_path()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 20
rs 9.9332
c 1
b 0
f 0
cc 3
nc 3
nop 2
1
<?php
2
3
if (false === function_exists('get_artomator_template_file_path')) {
4
    /**
5
     * get path for template file.
6
     *
7
     * @param string $templateName
8
     * @param string $templateType
9
     *
10
     * @return string
11
     */
12
    function get_artomator_template_file_path($templateName, $templateType)
13
    {
14
        $templateName = str_replace('.', '/', $templateName);
15
16
        $templatesPath = config(
17
            'infyom.laravel_generator.path.templates_dir',
18
            resource_path('infyom/infyom-generator-templates/')
19
        );
20
21
        $path = $templatesPath.$templateName.'.stub';
22
23
        if (file_exists($path)) {
24
            return $path;
25
        }
26
27
        if (file_exists(base_path('vendor/pwweb/'.$templateType.'/templates/'.$templateName.'.stub'))) {
28
            return base_path('vendor/pwweb/'.$templateType.'/templates/'.$templateName.'.stub');
29
        }
30
31
        return base_path('vendor/infyomlabs/'.$templateType.'/templates/'.$templateName.'.stub');
32
    }
33
}//end if
34
35
if (false === function_exists('get_artomator_template')) {
36
    /**
37
     * get template contents.
38
     *
39
     * @param string $templateName
40
     * @param string $templateType
41
     *
42
     * @return string
43
     */
44
    function get_artomator_template($templateName, $templateType = 'artomator')
45
    {
46
        $path = get_artomator_template_file_path($templateName, $templateType);
47
48
        return file_get_contents($path);
49
    }
50
}//end if
51
52
if (false === function_exists('license_authors')) {
53
    /**
54
     * format authors for codeblock.
55
     *
56
     * @param string|array $authors
57
     *
58
     * @return string
59
     */
60
    function license_authors($authors)
61
    {
62
        if (true === is_array($authors)) {
63
            return implode("\n * @author    ", $authors);
64
        } else {
65
            return $authors;
66
        }
67
    }
68
}// end if
69