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.
Completed
Push — master ( bf1ef2...cd89f1 )
by Pedro
10:51 queued 06:31
created

ZendFrameworkOne   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 4
dl 0
loc 92
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 3 1
B getParams() 0 23 4
A parseFrameworkConfig() 0 22 3
B getMakeFileInstances() 0 22 4
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 20 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Classes\AdapterConfig;
4
5
use Classes\AdapterMakerFile\ZendFrameworkOne\DbTable;
6
use Classes\AdapterMakerFile\ZendFrameworkOne\Entity;
7
use Classes\AdapterMakerFile\ZendFrameworkOne\Model;
8
use Classes\AdapterMakerFile\ZendFrameworkOne\Peer;
9
10
require_once "Classes/AdapterConfig/AbstractAdapter.php";
11
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/DbTable.php";
12
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/Entity.php";
13
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/Model.php";
14
require_once "Classes/AdapterMakerFile/ZendFrameworkOne/Peer.php";
15
16
/**
17
 * @author Pedro Alarcao <[email protected]>
18
 * @link   https://github.com/pedro151/orm-generator
19
 */
20
class ZendFrameworkOne extends AbstractAdapter
21
{
22
23
    private $config;
24
25
    const SEPARETOR = "_";
26
27
    protected function init ()
28
    {
29
    }
30
31
    /**
32
     * retorna os parametros da configuração do framework
33
     *
34
     * @return array
35
     */
36
    protected function getParams ()
37
    {
38
        if ( ! $this->config or ! $this->isValidFrameworkFiles () )
0 ignored issues
show
Comprehensibility Best Practice introduced by
Using logical operators such as or instead of || is generally not recommended.

PHP has two types of connecting operators (logical operators, and boolean operators):

  Logical Operators Boolean Operator
AND - meaning and &&
OR - meaning or ||

The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like &&, or ||.

Let’s take a look at a few examples:

// Logical operators have lower precedence:
$f = false or true;

// is executed like this:
($f = false) or true;


// Boolean operators have higher precedence:
$f = false || true;

// is executed like this:
$f = (false || true);

Logical Operators are used for Control-Flow

One case where you explicitly want to use logical operators is for control-flow such as this:

$x === 5
    or die('$x must be 5.');

// Instead of
if ($x !== 5) {
    die('$x must be 5.');
}

Since die introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined with throw at this point:

// The following is currently a parse error.
$x === 5
    or throw new RuntimeException('$x must be 5.');

These limitations lead to logical operators rarely being of use in current PHP code.

Loading history...
39
        {
40
            return array ();
41
        }
42
43
        return array (
44
            //Driver do banco de dados
45
            'driver'   => $this->config[ 'adapter' ] ,
46
            //Nome do banco de dados
47
            'database' => $this->config[ 'params' ][ 'dbname' ] ,
48
            //Host do banco
49
            'host'     => $this->config[ 'params' ][ 'host' ] ,
50
            //Port do banco
51
            'port'     => isset( $this->config[ 'params' ][ 'port' ] )
52
                ? $this->config[ 'params' ][ 'port' ] : '' ,
53
            //usuario do banco
54
            'username' => $this->config[ 'params' ][ 'username' ] ,
55
            //senha do banco
56
            'password' => $this->config[ 'params' ][ 'password' ] ,
57
        );
58
    }
59
60
    protected function parseFrameworkConfig ()
61
    {
62
        if ( ! $this->isValidFrameworkFiles () )
63
        {
64
            return;
65
        }
66
67
        $frameworkIni = $this->getFrameworkIni ();
68
69
        require_once 'Zend/Config/Ini.php';
70
71
        $objConfig = new \Zend_Config_Ini(
72
            realpath ( $frameworkIni ) , $this->getEnvironment ()
73
        );
74
75
        $arrConfig = $objConfig->toArray ();
76
77
        if ( isset( $arrConfig[ 'resources' ][ 'db' ] ) )
78
        {
79
            $this->config = $arrConfig[ 'resources' ][ 'db' ];
80
        }
81
    }
82
83
    /**
84
     * Cria Instancias dos arquivos que devem ser gerados
85
     *
86
     * @return \Classes\AdapterMakerFile\AbstractAdapter[]
87
     */
88
    public function getMakeFileInstances ()
89
    {
90
91
        $instances = array ();
92
        if ( $this->hasOptionalClasses () )
93
        {
94
            foreach ( $this->getOptionalClasses () as $optionalClass )
95
            {
96
                $Name = ucfirst ( $optionalClass );
97
                $className = "Classes\\AdapterMakerFile\\ZendFrameworkOne\\{$Name}";
98
                if(method_exists($className,'getInstance')){
99
                    $instances[] = $className::getInstance ();
100
                }
101
            }
102
        }
103
104
        return array_merge ( array (
105
            DbTable::getInstance () ,
106
            Entity::getInstance () ,
107
            Model::getInstance ()
108
        ) , $instances );
109
    }
110
111
}
112