Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | trait TReadFileTable |
||
16 | { |
||
17 | use TFinder; |
||
18 | use TStore; |
||
19 | |||
20 | /** |
||
21 | * @param Records\ARecord|Records\PageRecord $record |
||
22 | * @throws MapperException |
||
23 | * @return int |
||
24 | */ |
||
25 | 1 | public function countRecord(Records\ARecord $record): int |
|
26 | { |
||
27 | 1 | return count($this->findMatched($record)); |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param Records\ARecord|Records\PageRecord $record |
||
32 | * @throws MapperException |
||
33 | * @return bool |
||
34 | */ |
||
35 | 6 | protected function loadRecord(Records\ARecord $record): bool |
|
36 | { |
||
37 | 6 | $this->clearSource(); |
|
38 | 6 | $matches = $this->findMatched($record); |
|
39 | 6 | if (empty($matches)) { // nothing found |
|
40 | 2 | return false; |
|
41 | } |
||
42 | |||
43 | 5 | reset($matches); |
|
44 | 5 | $dataLine = & $this->records[key($matches)]; |
|
45 | 5 | foreach ($this->getRelations() as $objectKey => $recordKey) { |
|
46 | 5 | $entry = $record->getEntry($objectKey); |
|
47 | 5 | $entry->setData($dataLine->offsetGet($objectKey), true); |
|
48 | } |
||
49 | 5 | return true; |
|
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param Records\ARecord $record |
||
54 | * @throws MapperException |
||
55 | * @return Records\ARecord[] |
||
56 | */ |
||
57 | 15 | public function loadMultiple(Records\ARecord $record): array |
|
60 | } |
||
61 | } |
||
62 |