PubmedWebsite::getRequestOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace PubPeerFoundation\PublicationDataExtractor\Resources;
4
5
class PubmedWebsite extends Resource
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $url = 'https://www.ncbi.nlm.nih.gov/pubmed/';
11
12
    /**
13
     * @var array
14
     */
15
    protected $queryStringParameters = [
16
        'query' => [
17
            'term' => '',
18
        ],
19
    ];
20
21
    /**
22
     * @return array
23
     */
24
    public function getRequestOptions(): array
25
    {
26
        $this->queryStringParameters['query']['term'] = $this->identifier->getQueryString();
27
28
        return $this->queryStringParameters;
29
    }
30
31
    /**
32
     * @param  string  $document
33
     * @return array
34
     */
35
    public function getDataFrom(string $document): array
36
    {
37
        try {
38
            $extractor = new Extractors\PubmedWebsite($document, $this->output);
39
40
            return $extractor->extract();
41
        } catch (\Exception $e) {
42
            return [];
43
        }
44
    }
45
}
46