Completed
Push — master ( 81d4f7...748e62 )
by Beniamin
02:30
created

QB::select()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * This file is part of Phuria SQL Builder package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\SQLBuilder;
13
14
use Interop\Container\ContainerInterface;
15
use Phuria\SQLBuilder\DependencyInjection\InternalContainer;
16
use Phuria\SQLBuilder\QueryBuilder\DeleteBuilder;
17
use Phuria\SQLBuilder\QueryBuilder\InsertBuilder;
18
use Phuria\SQLBuilder\QueryBuilder\InsertSelectBuilder;
19
use Phuria\SQLBuilder\QueryBuilder\SelectBuilder;
20
use Phuria\SQLBuilder\QueryBuilder\UpdateBuilder;
21
22
/**
23
 * @author Beniamin Jonatan Šimko <[email protected]>
24
 */
25
class QB
0 ignored issues
show
Coding Style introduced by
QB does not seem to conform to the naming convention (Utils?$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
26
{
27
    /**
28
     * @var ContainerInterface $container
29
     */
30
    private static $container;
31
32
    /**
33
     * @return ContainerInterface
34
     */
35
    public static function getContainer()
36
    {
37
        if (null === static::$container) {
0 ignored issues
show
Bug introduced by
Since $container is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $container to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
38
            static::$container = new InternalContainer();
0 ignored issues
show
Bug introduced by
Since $container is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $container to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
Documentation Bug introduced by
It seems like new \Phuria\SQLBuilder\D...ion\InternalContainer() of type object<Phuria\SQLBuilder...tion\InternalContainer> is incompatible with the declared type object<Interop\Container\ContainerInterface> of property $container.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
39
        }
40
41
        return static::$container;
0 ignored issues
show
Bug introduced by
Since $container is declared private, accessing it with static will lead to errors in possible sub-classes; consider using self, or increasing the visibility of $container to at least protected.

Let’s assume you have a class which uses late-static binding:

class YourClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return static::$someVariable;
    }
}

The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the getSomeVariable() on that sub-class, you will receive a runtime error:

class YourSubClass extends YourClass { }

YourSubClass::getSomeVariable(); // Will cause an access error.

In the case above, it makes sense to update SomeClass to use self instead:

class SomeClass
{
    private static $someVariable;

    public static function getSomeVariable()
    {
        return self::$someVariable; // self works fine with private.
    }
}
Loading history...
Bug Compatibility introduced by
The expression static::$container; of type Phuria\SQLBuilder\Depend...iner\ContainerInterface adds the type Phuria\SQLBuilder\Depend...ction\InternalContainer to the return on line 41 which is incompatible with the return type documented by Phuria\SQLBuilder\QB::getContainer of type Interop\Container\ContainerInterface.
Loading history...
42
    }
43
44
    /**
45
     * @return SelectBuilder
46
     */
47
    public static function select()
48
    {
49
        return new SelectBuilder(static::getContainer());
50
    }
51
52
    /**
53
     * @return UpdateBuilder
54
     */
55
    public static function update()
56
    {
57
        return new UpdateBuilder(static::getContainer());
58
    }
59
60
    /**
61
     * @return DeleteBuilder
62
     */
63
    public static function delete()
64
    {
65
        return new DeleteBuilder(static::getContainer());
66
    }
67
68
    /**
69
     * @return InsertBuilder
70
     */
71
    public static function insert()
72
    {
73
        return new InsertBuilder(static::getContainer());
74
    }
75
76
    /**
77
     * @return InsertSelectBuilder
78
     */
79
    public static function insertSelect()
80
    {
81
        return new InsertSelectBuilder(static::getContainer());
82
    }
83
}