Completed
Push — master ( e8b047...677a25 )
by Andreas
02:35
created

MongoGridFSCursor::getNext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 1
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 */
15
16
class MongoGridFSCursor extends MongoCursor
1 ignored issue
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
17
{
18
    /**
19
     * @static
20
     * @var $slaveOkay
21
     */
22
    public static $slaveOkay;
23
24
    /**
25
     * @link http://php.net/manual/en/class.mongogridfscursor.php#mongogridfscursor.props.gridfs
26
     * @var $gridfs
27
     */
28
    protected $gridfs;
29
30
    /**
31
     * Create a new cursor
32
     *
33
     * @link http://php.net/manual/en/mongogridfscursor.construct.php
34
     * @param MongoGridFS $gridfs Related GridFS collection
35
     * @param MongoClient $connection Database connection
36
     * @param string $ns Full name of database and collection
37
     * @param array $query Database query
38
     * @param array $fields Fields to return
39
     * @return MongoGridFSCursor Returns the new cursor
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
40
     */
41
    public function __construct(MongoGridFS $gridfs, MongoClient $connection, $ns, array $query = array(), array $fields = array())
42
    {
43
        $this->gridfs = $gridfs;
44
        parent::__construct($connection, $ns, $query, $fields);
45
    }
46
47
    /**
48
     * Returns the current file
49
     *
50
     * @link http://php.net/manual/en/mongogridfscursor.current.php
51
     * @return MongoGridFSFile The current file
52
     */
53
    public function current()
54
    {
55
        $file = parent::current();
56
        return ($file !== null) ? new MongoGridFSFile($this->gridfs, $file) : null;
0 ignored issues
show
Bug Compatibility introduced by
The expression $file !== null ? new \Mo...>gridfs, $file) : null; of type MongoGridFSFile|null adds the type MongoGridFSFile to the return on line 56 which is incompatible with the return type of the parent method Alcaeus\MongoDbAdapter\AbstractCursor::current of type MongoId|MongoBinData|Mon...ble|string|null|boolean.
Loading history...
57
    }
58
59
    /**
60
     * Returns the current result's filename
61
     *
62
     * @link http://php.net/manual/en/mongogridfscursor.key.php
63
     * @return string The current results filename
64
     */
65
    public function key()
66
    {
67
        $file = $this->current();
68
        return ($file !== null) ? $file->getFilename() : null;
69
    }
70
}
71