Completed
Push — dev ( 798ae0...4b619a )
by James Ekow Abaka
04:30
created

DatabaseManipulatorFactory::createManipulator()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "DatabaseManipulatorFactory.php" doesn't match the expected filename "databasemanipulatorfactory.php"
Loading history...
2
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
/*
0 ignored issues
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
4
 * The MIT License
0 ignored issues
show
Coding Style introduced by
First line of comment not aligned correctly; expected 4 spaces but found 1
Loading history...
5
 *
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
6
 * Copyright 2017 ekow.
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
7
 *
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
9
 * of this software and associated documentation files (the "Software"), to deal
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
10
 * in the Software without restriction, including without limitation the rights
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
12
 * copies of the Software, and to permit persons to whom the Software is
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
13
 * furnished to do so, subject to the following conditions:
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
14
 *
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
15
 * The above copyright notice and this permission notice shall be included in
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
16
 * all copies or substantial portions of the Software.
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
17
 *
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
24
 * THE SOFTWARE.
0 ignored issues
show
Coding Style introduced by
Comment line indented incorrectly; expected at least 4 spaces but found 1
Loading history...
25
 */
0 ignored issues
show
Coding Style introduced by
Last line of comment aligned incorrectly; expected 0 spaces but found 1
Loading history...
26
27
namespace yentu\factories;
28
29
use clearice\io\Io;
30
use yentu\manipulators\AbstractDatabaseManipulator;
31
use ntentan\atiaa\DriverFactory;
32
33
/**
34
 * Description of DatabaseManipulatorFactory
35
 *
36
 * @author ekow
0 ignored issues
show
Coding Style Documentation introduced by
@author tag is not allowed in class comment
Loading history...
Coding Style introduced by
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
37
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
38
class DatabaseManipulatorFactory
39
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class DatabaseManipulatorFactory
Loading history...
40
    private $driverFactory;
0 ignored issues
show
Coding Style introduced by
Private member variable "driverFactory" 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 "driverFactory" must be prefixed with an underscore
Loading history...
41
    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...
42
    
43 41
    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...
Coding Style introduced by
Missing function doc comment
Loading history...
44
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
45 41
        $this->driverFactory = $driverFactory;
46 41
        $this->io = $io;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 12 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...
47 41
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
48
    
49 32
    public function createManipulator() : AbstractDatabaseManipulator
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
50
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
51 32
        $class = "\\yentu\\manipulators\\" . ucfirst($this->driverFactory->getConfig()['driver']);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal \\yentu\\manipulators\\ 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
Concat operator must not be surrounded by spaces
Loading history...
52 32
        return new $class($this->driverFactory, $this->io);
53
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
54
55 32
    public function createManipulatorWithConfig($config) : AbstractDatabaseManipulator
0 ignored issues
show
Coding Style introduced by
Missing function doc comment
Loading history...
56
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
57 32
        $this->driverFactory->setConfig($config);
58 32
        return $this->createManipulator();
59
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
60
61
}
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...
62