Passed
Push — dev ( 4b619a...66d037 )
by James Ekow Abaka
01:56
created

AbstractDatabaseManipulator::getDefaultSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
This file is missing a doc comment.
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "AbstractDatabaseManipulator.php" doesn't match the expected filename "abstractdatabasemanipulator.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace yentu\manipulators;
4
5
use clearice\io\Io;
6
use ntentan\atiaa\DriverFactory;
7
use yentu\Yentu;
8
use yentu\DatabaseAssertor;
9
use yentu\SchemaDescription;
10
use yentu\exceptions\DatabaseManipulatorException;
11
use yentu\Parameters;
12
13
abstract class AbstractDatabaseManipulator
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
14
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AbstractDatabaseManipulator
Loading history...
15
16
    const CONVERT_TO_DRIVER = 'driver';
17
    const CONVERT_TO_YENTU = 'yentu';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
18
19
    private $schemaDescription;
0 ignored issues
show
Coding Style introduced by
Private member variable "schemaDescription" must contain a leading underscore
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "schemaDescription" must be prefixed with an underscore
Loading history...
20
    private $assertor;
0 ignored issues
show
Coding Style introduced by
Private member variable "assertor" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "assertor" must be prefixed with an underscore
Loading history...
21
    private $connection;
0 ignored issues
show
Coding Style introduced by
Private member variable "connection" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "connection" must be prefixed with an underscore
Loading history...
22
    private $dumpQuery;
0 ignored issues
show
Coding Style introduced by
Private member variable "dumpQuery" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "dumpQuery" must be prefixed with an underscore
Loading history...
23
    private $disableQuery;
0 ignored issues
show
Coding Style introduced by
Private member variable "disableQuery" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "disableQuery" must be prefixed with an underscore
Loading history...
24
    protected $defaultSchema;
0 ignored issues
show
Coding Style introduced by
Protected member variable "defaultSchema" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
25
    private $io;
0 ignored issues
show
Coding Style introduced by
Private member variable "io" must contain a leading underscore
Loading history...
Coding Style introduced by
Expected 1 blank line before member var; 0 found
Loading history...
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
Coding Style introduced by
Private member variable "io" must be prefixed with an underscore
Loading history...
26
27
    /**
28
     * AbstractDatabaseManipulator constructor.
29
     * @param DriverFactory $driverFactory
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
30
     * @param Io $io
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 12 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
31
     * @throws \ntentan\atiaa\exceptions\ConnectionException
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
introduced by
Comment missing for @throws tag in function comment
Loading history...
32
     */
33 36
    public function __construct(DriverFactory $driverFactory, Io $io)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35 36
        $this->connection = $driverFactory->createDriver();
36 36
        $this->connection->connect();
37 36
        $this->io = $io;
38 36
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
39
40 36
    public function __get($name)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
41
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
42 36
        if ($name === 'description') {
43 36
            return $this->getDescription();
44
        }
45
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
46
47 11
    public function setDumpQuery($dumpQuery)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
48
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
49 11
        $this->dumpQuery = $dumpQuery;
50 11
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
51
52 11
    public function setDisableQuery($disableQuery)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
53
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
54 11
        $this->disableQuery = $disableQuery;
55 11
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
56
57 33
    public function __call($name, $arguments)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
58
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
59 33
        if (preg_match("/^(add|drop|change|executeQuery|reverseQuery)/", $name)) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /^(add|drop|change|executeQuery|reverseQuery)/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
60 33
            $details = Parameters::wrap($arguments[0]);
61 33
            $this->description->$name($details);
0 ignored issues
show
Bug Best Practice introduced by
The property description does not exist on yentu\manipulators\AbstractDatabaseManipulator. Since you implemented __get, consider adding a @property annotation.
Loading history...
62 33
            $name = "_$name";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $name instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
63 33
            new \ReflectionMethod($this, $name);
64 33
            return $this->$name($details);
65
        } else {
66
            throw new \Exception("Failed to execute method '$name'");
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $name instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
67
        }
68
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
69
70 33
    public function query($query, $bind = false)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$bind" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$bind"; expected 0 but found 1
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
71
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
72
        try {
73 33
            if ($this->dumpQuery) {
74
                echo "$query\n";
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $query instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
75
            }
76
77 33
            $this->io->output("\n    > Running Query [$query]", Io::OUTPUT_LEVEL_3);
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $query instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
78
79 33
            if ($this->disableQuery !== true) {
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
80 33
                return $this->connection->query($query, $bind);
81
            }
82
        } catch (\ntentan\atiaa\exceptions\DatabaseDriverException $e) {
83
            throw new DatabaseManipulatorException($e->getMessage());
84
        }
85 11
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
86
87 30
    public function disconnect()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
88
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
89 30
        $this->connection->disconnect();
90 30
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
91
92 2
    public function getDefaultSchema()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
93
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
94 2
        return $this->connection->getDefaultSchema();
95
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
96
97 33
    public function getAssertor()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
98
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
99 33
        if (!is_object($this->assertor)) {
0 ignored issues
show
Coding Style introduced by
There must be a single space after a NOT operator; 0 found
Loading history...
100 33
            $this->assertor = new DatabaseAssertor($this->description);
0 ignored issues
show
Bug Best Practice introduced by
The property description does not exist on yentu\manipulators\AbstractDatabaseManipulator. Since you implemented __get, consider adding a @property annotation.
Loading history...
101
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
102 33
        return $this->assertor;
103
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
104
105
    abstract protected function _addSchema($name);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addSchema" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
106
107
    abstract protected function _dropSchema($name);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropSchema" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
108
109
    abstract protected function _addTable($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addTable" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
110
111
    abstract protected function _dropTable($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropTable" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
112
113
    abstract protected function _changeTableName($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeTableName" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
114
115
    abstract protected function _addColumn($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addColumn" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
116
117
    abstract protected function _changeColumnNulls($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeColumnNulls" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
118
119
    abstract protected function _changeColumnName($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeColumnName" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
120
121
    abstract protected function _changeColumnDefault($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeColumnDefault" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
122
123
    abstract protected function _dropColumn($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropColumn" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
124
125
    abstract protected function _addPrimaryKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addPrimaryKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
126
127
    abstract protected function _dropPrimaryKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropPrimaryKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
128
129
    abstract protected function _addUniqueKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addUniqueKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
130
131
    abstract protected function _dropUniqueKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropUniqueKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
132
133
    abstract protected function _addAutoPrimaryKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addAutoPrimaryKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
134
135
    abstract protected function _dropAutoPrimaryKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropAutoPrimaryKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
136
137
    abstract protected function _addForeignKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addForeignKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
138
139
    abstract protected function _dropForeignKey($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropForeignKey" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
140
141
    abstract protected function _addIndex($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addIndex" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
142
143
    abstract protected function _dropIndex($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropIndex" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
144
145
    abstract protected function _addView($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_addView" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
146
147
    abstract protected function _dropView($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_dropView" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
148
149
    abstract protected function _changeViewDefinition($details);
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeViewDefinition" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
150
151
    protected function _changeForeignKeyOnDelete($details)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeForeignKeyOnDelete" must not be prefixed with an underscore
Loading history...
152
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
153
        $this->_dropForeignKey($details['from']);
154
        $this->_addForeignKey($details['to']);
155
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
156
157
    protected function _changeForeignKeyOnUpdate($details)
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_changeForeignKeyOnUpdate" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
158
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
159
        $this->_dropForeignKey($details['from']);
160
        $this->_addForeignKey($details['to']);
161
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
162
163
    protected function _executeQuery($details)
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_executeQuery" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
164
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
165
        $this->query($details['query'], $details['bind'] ?? []);
0 ignored issues
show
Coding Style introduced by
Arithmetic operation must be bracketed
Loading history...
Coding Style introduced by
Short array syntax is not allowed
Loading history...
166
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
167
168
    protected function _reverseQuery($details)
0 ignored issues
show
Coding Style introduced by
Protected method name "AbstractDatabaseManipulator::_reverseQuery" must not be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing function doc comment
Loading history...
169
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
170
        
171
    }
0 ignored issues
show
Coding Style introduced by
Function closing brace must go on the next line following the body; found 1 blank lines before brace
Loading history...
172
173
    abstract public function convertTypes($type, $direction, $length);
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
174
175
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
176
     * 
177
     * @return SchemaDescription
178
     */
179 36
    public function getDescription()
180
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
181 36
        if (!is_object($this->schemaDescription)) {
0 ignored issues
show
Coding Style introduced by
There must be a single space after a NOT operator; 0 found
Loading history...
182 36
            $this->schemaDescription = SchemaDescription::wrap($this->connection->describe(), $this);
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
183
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
184 36
        return $this->schemaDescription;
185
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
186
187 10
    public function setVersion($version)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
188
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
189 10
        $this->query('INSERT INTO yentu_history(version) values (?)', array($version));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
190 10
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
191
192
    public function getVersion()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
193
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
194
        $version = $this->query("SELECT MAX(version) as version FROM yentu_history");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal SELECT MAX(version) as version FROM yentu_history does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
195
        return isset($version[0]) ? $version[0]['version'] : null;
0 ignored issues
show
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
196
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
197
198 6
    public function getLastSession()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
199
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
200 6
        $session = $this->query("SELECT session FROM yentu_history ORDER BY id DESC LIMIT 1");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal SELECT session FROM yent...RDER BY id DESC LIMIT 1 does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
201 6
        return isset($session[0]['session']) ? $session[0]['session'] : null;
0 ignored issues
show
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
202
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
203
204 3
    public function getSessionVersions($session)
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
205
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
206 3
        $sessionVersions = array();
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
207 3
        $versions = $this->query(
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
208 3
            "SELECT DISTINCT version FROM yentu_history WHERE session = ?", array($session)
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal SELECT DISTINCT version ...story WHERE session = ? does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
209
        );
210
211 3
        foreach ($versions as $version) {
212 3
            $sessionVersions[] = $version['version'];
213
        }
214
215 3
        return $sessionVersions;
216
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
217
218 30
    public function createHistory()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
219
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
220
        try {
221 30
            $this->connection->describeTable('yentu_history');
222 30
        } catch (\ntentan\atiaa\exceptions\TableNotFoundException $e) {
223 30
            $this->io->pushOutputLevel(Io::OUTPUT_LEVEL_0);
224 30
            $this->addTable(array('schema' => '', 'name' => 'yentu_history'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Bug introduced by
The method addTable() does not exist on yentu\manipulators\AbstractDatabaseManipulator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

224
            $this->/** @scrutinizer ignore-call */ 
225
                   addTable(array('schema' => '', 'name' => 'yentu_history'));
Loading history...
225
226 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'session', 'type' => 'string'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 175 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
Bug introduced by
The method addColumn() does not exist on yentu\manipulators\AbstractDatabaseManipulator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

226
            $this->/** @scrutinizer ignore-call */ 
227
                   addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'session', 'type' => 'string'));
Loading history...
227 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => false, 'length' => null, 'table' => 'yentu_history', 'name' => 'version', 'type' => 'string'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 176 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
228 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'method', 'type' => 'string'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 174 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
229 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'arguments', 'type' => 'text'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 175 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
230 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'migration', 'type' => 'string'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 177 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
231 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'default_schema', 'type' => 'string'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 182 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
232 30
            $this->addColumn(array('default' => null, 'schema' => '', 'nulls' => true, 'length' => null, 'table' => 'yentu_history', 'name' => 'id', 'type' => 'integer'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 171 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
233 30
            $this->addPrimaryKey(array('schema' => '', 'table' => 'yentu_history', 'name' => 'yentu_history_pk', 'columns' => array('id')));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 140 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
Bug introduced by
The method addPrimaryKey() does not exist on yentu\manipulators\AbstractDatabaseManipulator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

233
            $this->/** @scrutinizer ignore-call */ 
234
                   addPrimaryKey(array('schema' => '', 'table' => 'yentu_history', 'name' => 'yentu_history_pk', 'columns' => array('id')));
Loading history...
234 30
            $this->addAutoPrimaryKey(array('schema' => '', 'table' => 'yentu_history', 'column' => 'id'));
0 ignored issues
show
Coding Style introduced by
Short array syntax must be used to define arrays
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 106 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
Bug introduced by
The method addAutoPrimaryKey() does not exist on yentu\manipulators\AbstractDatabaseManipulator. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

234
            $this->/** @scrutinizer ignore-call */ 
235
                   addAutoPrimaryKey(array('schema' => '', 'table' => 'yentu_history', 'column' => 'id'));
Loading history...
235 30
            $this->io->popOutputLevel();
236
        }
237 30
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
238
239 11
    public function __clone()
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
240
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
241 11
        if (is_object($this->schemaDescription)) {
242
            $this->schemaDescription = clone $this->schemaDescription;
243
        }
244 11
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
245
246
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
247