Skip to content

Commit a8d4eb9

Browse files
authored
Merge pull request #1 from AntoninoBonanno/master
Update Scopus-api-php
2 parents 3c43d69 + b6b71fc commit a8d4eb9

18 files changed

Lines changed: 907 additions & 138 deletions

README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ Currently supported APIs:
77
- Abstract Retrieval API
88
- Author Retrieval API
99
- Affiliation Retrieval API
10+
- Search Author API
11+
- Citation Overview API
12+
13+
Original Project: [https://github.com/kasparsj/scopus-api-php](https://github.com/kasparsj/scopus-api-php)
14+
15+
Custom Project: [https://github.com/AntoninoBonanno/scopus-api-php](https://github.com/AntoninoBonanno/scopus-api-php)
1016

1117
## Installation
1218

13-
`composer require kasparsj/scopus-search-api`
19+
`composer require kasparsj/scopus-search-api` (Original project)
20+
21+
Overwrite this project to the original project if you want to use my updates
1422

1523
## Usage:
1624

@@ -54,3 +62,11 @@ foreach ($results->getEntries() as $entry) {
5462
## API Docs
5563

5664
https://kasparsj.github.io/scopus-api-php/
65+
66+
## My contribution
67+
* Added Search Author API
68+
* Added Citation Overview API
69+
* Created a support function to retrieve Document of specific Author easly
70+
* Updated classes
71+
72+
[Bonanno Antonino](https://github.com/AntoninoBonanno)

composer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33
"description": "Scopus API for PHP (Unofficial)",
44
"minimum-stability": "dev",
55
"license": "MIT",
6+
"version": "1.1",
67
"authors": [
78
{
89
"name": "Kaspars Jaudzems",
910
"email": "kasparsj@gmail.com"
11+
},
12+
{
13+
"name": "Antonino Bonanno",
14+
"email": "nino.bonanno96@gmail.com"
1015
}
1116
],
1217
"require": {
1318
"guzzlehttp/guzzle": "6.2.1"
1419
},
1520
"autoload": {
16-
"psr-0": { "Scopus\\": "src/" }
21+
"psr-0": {
22+
"Scopus\\": "src/"
23+
}
1724
}
18-
}
25+
}

src/Scopus/Response/AbstractAuthor.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ class AbstractAuthor extends AuthorName implements IAuthor
66
{
77
/** @var array */
88
protected $data;
9-
9+
1010
/** @var AuthorName */
1111
protected $preferredName;
1212

1313
public function __construct(array $data)
1414
{
1515
parent::__construct($data, 'ce');
1616
}
17-
17+
1818
public function getId()
1919
{
2020
return $this->data['@auid'];
2121
}
22-
22+
2323
public function getSeq()
2424
{
25-
return $this->data['@seq'];
25+
return $this->data['@seq'];
2626
}
27-
27+
2828
public function getPreferredName()
2929
{
3030
return $this->preferredName ?: $this->preferredName = new AuthorName($this->data['preferred-name'], 'ce');
@@ -34,4 +34,4 @@ public function getUrl()
3434
{
3535
return $this->data['author-url'];
3636
}
37-
}
37+
}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?php
2+
3+
namespace Scopus\Response;
4+
5+
class AbstractCitations
6+
{
7+
/** @var array */
8+
protected $data;
9+
10+
/** @var AbstractCoredata[] */
11+
protected $identifiers;
12+
13+
/** @var CiteInfo[] */
14+
protected $citeInfos;
15+
16+
/** @var CiteCountHeader */
17+
protected $citeCountHeader;
18+
19+
public function __construct(array $data)
20+
{
21+
$this->data = $data;
22+
}
23+
24+
public function getHindex()
25+
{
26+
return $this->data['h-index'];
27+
}
28+
29+
public function getIdentifiers()
30+
{
31+
if (isset($this->data['identifier-legend']['identifier'])) {
32+
return $this->identifiers ?: $this->identifiers = array_map(function ($identifier) {
33+
return new AbstractCoredata($identifier);
34+
}, $this->data['identifier-legend']['identifier']);
35+
}
36+
return null;
37+
}
38+
39+
public function getCiteInfos()
40+
{
41+
if (isset($this->data['citeInfoMatrix']['citeInfoMatrixXML']['citationMatrix']['citeInfo'])) {
42+
return $this->citeInfos ?: $this->citeInfos = array_map(function ($citeInfo) {
43+
return new CiteInfo($citeInfo);
44+
}, $this->data['citeInfoMatrix']['citeInfoMatrixXML']['citationMatrix']['citeInfo']);
45+
}
46+
return null;
47+
}
48+
49+
public function getCiteCountHeader()
50+
{
51+
if (isset($this->data['citeColumnTotalXML']['citeCountHeader']))
52+
return $this->citeCountHeader ?? $this->citeCountHeader = new CiteCountHeader($this->data['citeColumnTotalXML']['citeCountHeader']);
53+
54+
return null;
55+
}
56+
57+
/**
58+
* Extracts the citations per year of each document
59+
* @return array [document_scopus_id => [year => value ]]
60+
*/
61+
public function getCompactInfo()
62+
{
63+
$header = $this->getCiteCountHeader();
64+
if (!$header) return null;
65+
66+
$clmHeader = $header->getColumnHeading();
67+
$citeInfos = $this->getCiteInfos();
68+
69+
if (!$clmHeader || !$citeInfos) return null;
70+
if (!is_array($clmHeader)) return [$citeInfos[0]->getScopusId() => [$clmHeader => $citeInfos[0]->getColumnCount()]];
71+
72+
$compactData = [];
73+
foreach ($citeInfos as $citeInfo) {
74+
foreach ($clmHeader as $index => $value) {
75+
$compactData[$citeInfo->getScopusId()][$value["$"]] = $citeInfo->getColumnCount()[$index]["$"];
76+
}
77+
}
78+
return $compactData;
79+
}
80+
81+
/**
82+
* Extracts total citations per year
83+
* @return array [year => value ]
84+
*/
85+
public function getTotalCompactInfo()
86+
{
87+
$header = $this->getCiteCountHeader();
88+
if (!$header) return null;
89+
90+
$clmHeader = $header->getColumnHeading();
91+
$clmCount = $header->getColumnTotal();
92+
93+
if (!$clmHeader || !$clmCount) return null;
94+
if (!is_array($clmHeader)) $clmHeader = [$clmHeader];
95+
96+
$compactData = [];
97+
$compactData["citation_previous_dates"] = $header->getPrevColumnTotal();
98+
$compactData["citation_subsequent_dates"] = $header->getLaterColumnTotal();
99+
100+
foreach ($clmHeader as $index => $value)
101+
$compactData[$value["$"]] = $clmCount[$index]["$"];
102+
103+
return $compactData;
104+
}
105+
}

src/Scopus/Response/AbstractCoredata.php

Lines changed: 55 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class AbstractCoredata
66
{
77
/** @var array */
88
protected $data;
9-
9+
1010
public function __construct(array $data)
1111
{
1212
$this->data = $data;
@@ -16,12 +16,12 @@ public function getUrl()
1616
{
1717
return $this->data['prism:url'];
1818
}
19-
19+
2020
public function getIdentifier()
2121
{
2222
return isset($this->data['dc:identifier']) ? $this->data['dc:identifier'] : null;
2323
}
24-
24+
2525
public function getScopusId()
2626
{
2727
$identifier = $this->getIdentifier();
@@ -30,77 +30,98 @@ public function getScopusId()
3030
}
3131
}
3232

33-
public function getDoi()
33+
public function getEid()
3434
{
35-
return isset($this->data['prism:doi']) ? $this->data['prism:doi'] : null;
35+
return isset($this->data['eid']) ? $this->data['eid'] : null;
3636
}
3737

3838
public function getTitle()
3939
{
4040
return isset($this->data['dc:title']) ? $this->data['dc:title'] : null;
4141
}
4242

43-
public function getDescription()
43+
public function getPublicationName()
4444
{
45-
return $this->data['dc:description'];
45+
return isset($this->data['prism:publicationName']) ? $this->data['prism:publicationName'] : null;
4646
}
4747

48-
public function getPageRange()
48+
public function getEIssn()
4949
{
50-
return isset($this->data['prism:pageRange']) ? $this->data['prism:pageRange'] : null;
50+
return $this->data['prism:eIssn'];
5151
}
5252

53-
public function getStartPage()
53+
public function getVolume()
5454
{
55-
$pageRange = $this->getPageRange();
56-
if ($pageRange) {
57-
return explode('-', $pageRange)[0];
58-
}
55+
return $this->data['prism:volume'];
5956
}
6057

61-
public function getEndPage()
58+
public function getPageRange()
6259
{
63-
$pageRange = $this->getPageRange();
64-
if ($pageRange) {
65-
$startEndPage = explode('-', $pageRange);
66-
if (count($startEndPage) > 1) {
67-
return $startEndPage[1];
68-
}
69-
}
60+
return isset($this->data['prism:pageRange']) ? $this->data['prism:pageRange'] : null;
7061
}
7162

7263
public function getCoverDate()
7364
{
74-
return $this->data['prism:coverDate'];
65+
return isset($this->data['prism:coverDate']) ? $this->data['prism:coverDate'] : null;;
7566
}
7667

77-
public function getPublicationName()
68+
public function getDoi()
7869
{
79-
return isset($this->data['prism:publicationName']) ? $this->data['prism:publicationName'] : null;
70+
return isset($this->data['prism:doi']) ? $this->data['prism:doi'] : null;
8071
}
81-
82-
public function getIssn()
72+
73+
public function getPubmedId()
8374
{
84-
return $this->data['prism:issn'];
75+
return isset($this->data['pubmed-id']) ? $this->data['pubmed-id'] : null;
8576
}
8677

87-
public function getEIssn()
78+
public function getArticleNumber()
8879
{
89-
return $this->data['prism:eIssn'];
80+
return isset($this->data['article-number']) ? $this->data['article-number'] : null;
9081
}
9182

92-
public function getVolume()
83+
public function getDescription()
9384
{
94-
return $this->data['prism:volume'];
85+
return $this->data['dc:description'];
9586
}
9687

9788
public function getCitedbyCount()
9889
{
99-
return $this->data['citedby-count'];
90+
if (!isset($this->data['citedby-count'])) return 0;
91+
return is_array($this->data['citedby-count']) ? $this->data['citedby-count'][1]['$'] : $this->data['citedby-count'];
10092
}
10193

10294
public function getAggregationType()
10395
{
10496
return $this->data['prism:aggregationType'];
10597
}
106-
}
98+
99+
public function getFundSponsor()
100+
{
101+
return isset($this->data['fund-sponsor']) ? $this->data['fund-sponsor'] : null;
102+
}
103+
104+
public function getStartPage()
105+
{
106+
$pageRange = $this->getPageRange();
107+
if ($pageRange) {
108+
return explode('-', $pageRange)[0];
109+
}
110+
}
111+
112+
public function getEndPage()
113+
{
114+
$pageRange = $this->getPageRange();
115+
if ($pageRange) {
116+
$startEndPage = explode('-', $pageRange);
117+
if (count($startEndPage) > 1) {
118+
return $startEndPage[1];
119+
}
120+
}
121+
}
122+
123+
public function getIssn()
124+
{
125+
return $this->data['prism:issn'];
126+
}
127+
}

0 commit comments

Comments
 (0)