GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AbstractMaker::getClassName()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
namespace Classes\Maker;
3
4
abstract class AbstractMaker
5
{
6
    const SEPARETOR = '_';
7
8
    /**
9
     * verifica se ja existe e cria as pastas em cascata
10
     *
11
     * @param $dir
12
     */
13
    public static function makeDir ( $dir )
14
    {
15
        if ( !is_dir ( $dir ) )
16
        {
17
            if ( !@mkdir ( $dir, 0755, true ) )
18
            {
19
                die( "\033[0;31mError: could not create directory $dir\033[0m\n" );
0 ignored issues
show
Coding Style Compatibility introduced by
The method makeDir() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
20
            }
21
        }
22
    }
23
24
    /**
25
     * @param string $nameFile nome do arquivo a ser criado
26
     * @param string $tplContent Conteudo do Template
27
     * @param bool $overwrite Sobrescreve o arquivo ja existente
28
     *
29
     * @return boolean
30
     */
31
    public static function makeSourcer ( $nameFile, $tplContent, $overwrite = false )
32
    {
33
        if ( !$overwrite && is_file ( $nameFile ) )
34
        {
35
            return false;
36
        }
37
38
        if ( !file_put_contents ( $nameFile, $tplContent ) )
39
        {
40
            die( "\033[0;31mError: could not write model file $nameFile.\033[0m\n" );
0 ignored issues
show
Coding Style Compatibility introduced by
The method makeSourcer() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
41
        }
42
43
        return true;
44
    }
45
46
    /**
47
     * @param string $str
48
     *
49
     * @return string
50
     */
51
    public static function getClassName ( $str )
52
    {
53
        $temp = '';
54
        foreach ( explode ( self::SEPARETOR, $str ) as $part )
55
        {
56
            $temp .= ucfirst ( strtolower( $part ) );
57
        }
58
59
        return $temp;
60
    }
61
62
    protected function getParsedTplContents ( $filePath, $vars = array () )
63
    {
64
        extract ( $vars );
65
        ob_start ();
66
        require $filePath;
67
        $data = ob_get_contents ();
68
        ob_end_clean ();
69
70
        return $data;
71
    }
72
73
}