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