| Total Complexity | 6 |
| Total Lines | 59 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class OneToManyDataLoader |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var Connection |
||
| 13 | */ |
||
| 14 | private $connection; |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $sql; |
||
| 19 | /** |
||
| 20 | * @var string |
||
| 21 | */ |
||
| 22 | private $fkColumn; |
||
| 23 | /** |
||
| 24 | * @var array<string, array<int, array<string, mixed>>> Array of rows, indexed by foreign key. |
||
| 25 | */ |
||
| 26 | private $data; |
||
| 27 | |||
| 28 | public function __construct(Connection $connection, string $sql, string $fkColumn) |
||
| 29 | { |
||
| 30 | $this->connection = $connection; |
||
| 31 | $this->sql = $sql; |
||
| 32 | $this->fkColumn = $fkColumn; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return array<string, array<string, mixed>> Rows, indexed by ID. |
||
| 37 | */ |
||
| 38 | private function load(): array |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Returns the DB row with the given ID. |
||
| 52 | * Loads all rows if necessary. |
||
| 53 | * Throws an exception if nothing found. |
||
| 54 | * |
||
| 55 | * @param string $id |
||
| 56 | * @return array<string, mixed> |
||
| 57 | */ |
||
| 58 | public function get(string $id): array |
||
| 70 |