We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Total Complexity | 8 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
13 | class DatabaseResult { |
||
14 | |||
15 | public function __construct( |
||
16 | private readonly mysqli_result $dbResult |
||
17 | ) {} |
||
18 | |||
19 | /** |
||
20 | * Use to iterate over the records from the result set. |
||
21 | * @return \Generator<DatabaseRecord> |
||
22 | */ |
||
23 | public function records(): Generator { |
||
24 | foreach ($this->dbResult as $dbRecord) { |
||
25 | yield new DatabaseRecord($dbRecord); |
||
26 | } |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * Use when exactly one record is expected from the result set. |
||
31 | */ |
||
32 | public function record(): DatabaseRecord { |
||
33 | if ($this->getNumRecords() != 1) { |
||
34 | throw new RuntimeException('One record required, but found ' . $this->getNumRecords()); |
||
35 | } |
||
36 | return new DatabaseRecord($this->dbResult->fetch_assoc()); |
||
37 | } |
||
38 | |||
39 | public function getNumRecords(): int { |
||
45 | } |
||
46 | |||
47 | public function hasRecord(): bool { |
||
49 | } |
||
50 | |||
52 |