Skip to content

Commit 2344ad0

Browse files
committed
Citation Count API
1 parent c8288f6 commit 2344ad0

3 files changed

Lines changed: 131 additions & 1 deletion

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace Scopus\Response;
4+
5+
class CitationCount
6+
{
7+
const STATUS_FOUND = 'found';
8+
const STATUS_NOT_FOUND = 'not_found';
9+
10+
/**
11+
* @var array
12+
*/
13+
protected $data;
14+
15+
/**
16+
* @var CitationCountLinks
17+
*/
18+
protected $links;
19+
20+
public function __construct(array $data)
21+
{
22+
$this->data = $data;
23+
}
24+
25+
public function getStatus(): bool
26+
{
27+
return $this->data['@status'];
28+
}
29+
30+
public function getIdentifier()
31+
{
32+
return $this->data['dc:identifier'];
33+
}
34+
35+
public function getUrl()
36+
{
37+
return isset($this->data['prism:url']) ? $this->data['prism:url'] : null;
38+
}
39+
40+
public function getDoi()
41+
{
42+
return isset($this->data['prism:doi']) ? $this->data['prism:doi'] : null;
43+
}
44+
45+
public function getPii()
46+
{
47+
return isset($this->data['pii']) ? $this->data['pii'] : null;
48+
}
49+
50+
public function getPumbedId()
51+
{
52+
return isset($this->data['pubmed_id']) ? $this->data['pubmed_id'] : null;
53+
}
54+
55+
public function getEID()
56+
{
57+
return isset($this->data['eid']) ? $this->data['eid'] : null;
58+
}
59+
60+
public function getArticleNumber()
61+
{
62+
return isset($this->data['article-number']) ? $this->data['article-number'] : null;
63+
}
64+
65+
public function getCitationCount()
66+
{
67+
return isset($this->data['citation-count']) ? $this->data['citation-count'] : null;
68+
}
69+
70+
public function getLinks()
71+
{
72+
return $this->links ?: $this->links = new CitationCountLinks($this->data['link']);
73+
}
74+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Scopus\Response;
4+
5+
class CitationCountLinks
6+
{
7+
/**
8+
* @var array
9+
*/
10+
protected $links;
11+
12+
public function __construct(array $links)
13+
{
14+
$this->links = [];
15+
16+
foreach ($links as $link) {
17+
$this->links[$link['@rel']] = [
18+
'href' => $link['@href'],
19+
'fa' => $link['@_fa'],
20+
];
21+
}
22+
}
23+
}

src/Scopus/ScopusApi.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Scopus\Exception\XmlException;
99
use Scopus\Response\Abstracts;
1010
use Scopus\Response\Author;
11+
use Scopus\Response\CitationCount;
1112
use Scopus\Response\SearchResults;
1213
use Scopus\Response\AbstractCitations;
1314
use Scopus\Util\XmlUtil;
@@ -20,6 +21,7 @@ class ScopusApi
2021
const AFFILIATION_URI = 'https://api.elsevier.com/content/affiliation/affiliation_id/';
2122
const SEARCH_AUTHOR_URI = 'https://api.elsevier.com/content/search/author';
2223
const CITATION_OVERVIEW_URI = 'https://api.elsevier.com/content/abstract/citations';
24+
const CITATION_COUNT_URI = 'https://api.elsevier.com/content/abstract/citation-count';
2325
const TIMEOUT = 40.0;
2426

2527
protected $apiKey;
@@ -68,7 +70,7 @@ private function query($query)
6870
/**
6971
* @param string $uri
7072
* @param array $options
71-
* @return array|Abstracts|Author|SearchResults
73+
* @return array|Abstracts|Author|SearchResults|CitationCount[]
7274
* @throws Exception
7375
*/
7476
private function retrieve($uri, array $options = [])
@@ -112,6 +114,12 @@ private function retrieve($uri, array $options = [])
112114
}, $json['author-retrieval-response-list']['author-retrieval-response']);
113115
case 'abstract-citations-response':
114116
return new AbstractCitations($json['abstract-citations-response']);
117+
case 'citation-count-response':
118+
$document = $json['citation-count-response']['document'];
119+
120+
return array_map(function ($data) {
121+
return new CitationCount($data);
122+
}, isset($document['@status']) ? [$document] : $document);
115123
default:
116124
throw new Exception(sprintf('Unsupported response type: "%s" for "%s"', $type, $uri));
117125
}
@@ -190,6 +198,31 @@ public function overviewCitation($documentId, String $startYear = null, String $
190198
return $responses;
191199
}
192200

201+
/**
202+
* @param string|string[] $scopusId
203+
* @param array $options
204+
*
205+
* @return CitationCount[]
206+
*
207+
* @throws Exception
208+
*/
209+
public function retrieveCitationCount($scopusId, array $options = [])
210+
{
211+
if (is_array($scopusId)) {
212+
$scopusId = implode(',', $scopusId);
213+
}
214+
215+
if (count(explode(',', $scopusId)) > 25) {
216+
throw new Exception("The maximum number of 25 document id's exceeded!");
217+
}
218+
219+
$options['scopus_id'] = $scopusId;
220+
221+
return $this->retrieve(self::CITATION_COUNT_URI, [
222+
'query' => $options
223+
]);
224+
}
225+
193226
/**
194227
* @param $scopusId
195228
* @param array $options

0 commit comments

Comments
 (0)