Total Complexity | 6 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | class PubmedWebsite implements Extractor, ProvidesIdentifiersData, ProvidesAffiliationsData |
||
8 | { |
||
9 | protected $document; |
||
10 | |||
11 | protected $searchTree; |
||
12 | |||
13 | protected $output = []; |
||
14 | |||
15 | protected $crawler; |
||
16 | |||
17 | public function __construct($document) |
||
18 | { |
||
19 | $this->crawler = new Crawler(); |
||
20 | $this->crawler->addHtmlContent($document); |
||
21 | } |
||
22 | |||
23 | public function extract(): array |
||
24 | { |
||
25 | $this->extractIdentifiersData(); |
||
26 | $this->extractAffiliationsData(); |
||
27 | |||
28 | return $this->output; |
||
29 | } |
||
30 | |||
31 | public function extractIdentifiersData() |
||
32 | { |
||
33 | $pubmed = stringify($this->crawler->evaluate('string(//input[@id="absid"]/@value)')); |
||
34 | |||
35 | if (! empty($pubmed)) { |
||
36 | $this->output['identifiers'][] = [ |
||
37 | 'value' => $pubmed, |
||
38 | 'type' => 'pubmed', |
||
39 | ]; |
||
40 | } |
||
41 | } |
||
42 | |||
43 | public function extractAffiliationsData() |
||
50 | ]; |
||
51 | } |
||
52 | } |
||
53 | } |
||
54 |