We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Total Complexity | 7 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
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 { |
||
36 | } |
||
37 | |||
38 | public function hasRecord() : bool { |
||
40 | } |
||
41 | |||
43 |