Completed
Push — master ( d6fc27...dc9f7f )
by Hung
19s
created

MultiResultSet::store()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 24
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
c 0
b 0
f 0
rs 8.6845
cc 4
eloc 11
nc 4
nop 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A MultiResultSet::make() 0 5 1
1
<?php
2
3
namespace Foolz\SphinxQL\Drivers\Pdo;
4
5
6
use Foolz\SphinxQL\Drivers\MultiResultSetBase;
7
use PDOStatement;
8
9
class MultiResultSet extends MultiResultSetBase
10
{
11
    /**
12
     * @var PDOStatement
13
     */
14
    public $statement;
15
16
    /**
17
     * @param MultiResultSetAdapter $adapter
18
     * @param PDOStatement|array|int $statement
19
     */
20
    public function __construct(MultiResultSetAdapter $adapter, $statement)
21
    {
22
        $this->adapter = $adapter;
23
24
        if ($statement instanceof PDOStatement) {
25
            $this->statement = $statement;
26
        } else {
27
            $this->stored = $statement; // for php < 5.4.0
0 ignored issues
show
Documentation Bug introduced by
It seems like $statement can also be of type integer. However, the property $stored is declared as type null|array. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
28
        }
29
    }
30
31
    /**
32
     * @param PDOStatement|array|int $statement
33
     * @return MultiResultSet
34
     */
35
    public static function make($statement)
36
    {
37
        $adapter = new MultiResultSetAdapter($statement);
38
        return new MultiResultSet($adapter, $statement);
39
    }
40
}
41