Total Complexity | 7 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class IdConverter extends Extractor implements ProvidesIdentifiersData |
||
8 | { |
||
9 | /** |
||
10 | * @var array |
||
11 | */ |
||
12 | protected $typeMap = [ |
||
13 | 'pmcid' => 'pmc', |
||
14 | 'pmid' => 'pubmed', |
||
15 | 'doi' => 'doi', |
||
16 | ]; |
||
17 | |||
18 | /** |
||
19 | * Extract search tree from document. |
||
20 | * |
||
21 | * @throws UnparseableApiException |
||
22 | */ |
||
23 | protected function fillSearchTree(): void |
||
24 | { |
||
25 | if ('ok' !== $this->document['status']) { |
||
26 | throw new UnparseableApiException(); |
||
27 | } |
||
28 | |||
29 | if (isset($this->document['records'][0]['status']) && 'error' === $this->document['records'][0]['status']) { |
||
30 | throw new UnparseableApiException(); |
||
31 | } |
||
32 | |||
33 | $this->searchTree = $this->document['records'][0]; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * Extract and format data needed for the Identifiers Relationship |
||
38 | * on the Publication Model. |
||
39 | */ |
||
40 | public function extractIdentifiersData(): void |
||
47 | ]; |
||
48 | } |
||
52 |