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
Pull Request — master (#1094)
by Dan
04:47
created

DatabaseResult::record()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 5
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