Passed
Push — master ( b2b78e...4de28a )
by Sébastien
07:25
created

UpdateResultSet::asClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace Bdf\Prime\Connection\Result;
4
5
/**
6
 * Result set for update operation
7
 * Will return only the modified rows count
8
 */
9
final class UpdateResultSet extends \EmptyIterator implements ResultSetInterface
10
{
11
    /**
12
     * @var integer
0 ignored issues
show
introduced by
Expected "int" but found "integer" for @var tag in member variable comment
Loading history...
13
     */
14
    private $count;
15
16
17
    /**
18
     * UpdateResultSet constructor.
19
     *
20
     * @param int $count
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
21
     */
22 457
    public function __construct($count)
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before function; 2 found
Loading history...
23
    {
24 457
        $this->count = $count;
25 457
    }
26
27
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $mode should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $options should have a doc-comment as per coding-style.
Loading history...
28
     * {@inheritdoc}
29
     */
30 1
    public function fetchMode($mode, $options = null)
31
    {
32 1
        return $this;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function asAssociative(): ResultSetInterface
39
    {
40
        return $this;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function asList(): ResultSetInterface
47
    {
48
        return $this;
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function asObject(): ResultSetInterface
55
    {
56
        return $this;
57
    }
58
59
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $className should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $constructorArguments should have a doc-comment as per coding-style.
Loading history...
60
     * {@inheritdoc}
61
     */
62
    public function asClass(string $className, array $constructorArguments = []): ResultSetInterface
63
    {
64
        return $this;
65
    }
66
67
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $column should have a doc-comment as per coding-style.
Loading history...
68
     * {@inheritdoc}
69
     */
70
    public function asColumn(int $column = 0): ResultSetInterface
71
    {
72
        return $this;
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78 1
    public function all()
79
    {
80 1
        return [];
0 ignored issues
show
Bug Best Practice introduced by
The expression return array() returns the type array which is incompatible with the return type mandated by Bdf\Prime\Connection\Res...sultSetInterface::all() of Bdf\Prime\Connection\Result\list.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86 457
    public function count()
87
    {
88 457
        return $this->count;
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function isRead(): bool
95
    {
96
        return false;
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function isWrite(): bool
103
    {
104
        return true;
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110
    public function hasWrite(): bool
111
    {
112
        return $this->count > 0;
113
    }
114
}