Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Push — master ( f174b5...646f17 )
by Dan
21s queued 18s
created

DatabaseResult::getNumRecords()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Smr;
4
5
/**
6
 * Holds the result of a Database query (e.g. read or write).
7
 */
8
class DatabaseResult {
9
10
	public function __construct(
11
		private \mysqli_result $dbResult
12
	) {}
13
14
	/**
15
	 * Use to iterate over the records from the result set.
16
	 * @return \Generator<DatabaseRecord>
17
	 */
18
	public function records() : \Generator {
19
		foreach ($this->dbResult as $dbRecord) {
20
			yield new DatabaseRecord($dbRecord);
21
		}
22
	}
23
24
	/**
25
	 * Use when exactly one record is expected from the result set.
26
	 */
27
	public function record() : DatabaseRecord {
28
		if ($this->getNumRecords() != 1) {
29
			throw new \RuntimeException('One record required, but found ' . $this->getNumRecords());
30
		}
31
		return new DatabaseRecord($this->dbResult->fetch_assoc());
32
	}
33
34
	public function getNumRecords() : int {
35
		return $this->dbResult->num_rows;
36
	}
37
38
	public function hasRecord() : bool {
39
		return $this->getNumRecords() > 0;
40
	}
41
42
}
43