QueryResult   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 41
ccs 9
cts 9
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A fetch() 0 3 1
A getIterator() 0 3 1
A fetchAll() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of the miBadger package.
5
 *
6
 * @author Michael Webbers <[email protected]>
7
 * @license http://opensource.org/licenses/Apache-2.0 Apache v2 License
8
 */
9
10
namespace miBadger\Query;
11
12
/**
13
 * The query result class.
14
 *
15
 * @since 1.0.0
16
 */
17
class QueryResult implements \IteratorAggregate
18
{
19
	/** @var \PDOStatement The PDO statement. */
20
	private $pdoStatement;
21
22
	/**
23
	 * Construct a query result object with the given pdo statement.
24
	 *
25
	 * @param \PDOStatement $pdoStatement
26
	 */
27 4
	public function __construct(\PDOStatement $pdoStatement)
28
	{
29 4
		$this->pdoStatement = $pdoStatement;
30 4
	}
31
32
	/**
33
	 * {@inheritdoc}
34
	 */
35 1
	public function getIterator()
36
	{
37 1
		return $this->pdoStatement;
38
	}
39
40
	/**
41
	 * Fetches a row from the result set.
42
	 *
43
	 * @return mixed a row from the result set.
44
	 */
45 2
	public function fetch()
46
	{
47 2
		return $this->pdoStatement->fetch();
48
	}
49
50
	/**
51
	 * Fetches all rows from the result set.
52
	 *
53
	 * @return array all rows from the result set.
54
	 */
55 1
	public function fetchAll()
56
	{
57 1
		return $this->pdoStatement->fetchAll();
58
	}
59
}
60