Arxiv   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 39
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequestOptions() 0 5 1
A getDataFrom() 0 9 2
1
<?php
2
3
namespace PubPeerFoundation\PublicationDataExtractor\Resources;
4
5
use SimpleXMLElement;
6
7
class Arxiv extends Resource
8
{
9
    /**
10
     * @var string
11
     */
12
    protected $url = 'http://export.arxiv.org/api/query';
13
14
    /**
15
     * @var array
16
     */
17
    protected $queryStringParameters = [
18
        'query' => [
19
            'id_list' => '',
20
        ],
21
    ];
22 2
23
    /**
24 2
     * @return array
25 2
     */
26
    public function getRequestOptions(): array
27
    {
28
        $this->queryStringParameters['query']['id_list'] = $this->identifier->getQueryString();
29
30 1
        return $this->queryStringParameters;
31
    }
32 1
33
    /**
34
     * @param  string  $document
35
     * @return array
36
     */
37
    public function getDataFrom(string $document): array
38 1
    {
39
        try {
40 1
            $baseTree = new SimpleXMLElement($document);
41
            $extractor = new Extractors\Arxiv($baseTree, $this->output);
42
43
            return $extractor->extract();
44
        } catch (\Exception $e) {
45
            return [];
46
        }
47
    }
48
}
49