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