-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Xavier Roussel
committed
May 7, 2021
1 parent
3c23131
commit 4dddeaa
Showing
10 changed files
with
1,624 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace PubPeerFoundation\PublicationDataExtractor\Models; | ||
|
||
class Links extends Model | ||
{ | ||
/** | ||
* Hold cherry picked list of links. | ||
* | ||
* @var array | ||
*/ | ||
protected $list = []; | ||
|
||
/** | ||
* Add unknown links to the current list. | ||
*/ | ||
public function add(array $links): array | ||
{ | ||
foreach ($links as $link) { | ||
if ($this->hasPreprint($link)) { | ||
$this->list[] = $link; | ||
} | ||
if ($this->isPreprint($link)) { | ||
$this->list[] = $link; | ||
} | ||
} | ||
|
||
return $this->list; | ||
} | ||
|
||
private function hasPreprint(array $link): bool | ||
{ | ||
if (! array_key_exists('has_preprint', $link)) { | ||
return false; | ||
} | ||
|
||
return ! in_array(strtolower($link['has_preprint']), $this->knownIdentifierValues('has_preprint')); | ||
} | ||
|
||
private function isPreprint(array $link): bool | ||
{ | ||
if (! array_key_exists('is_preprint_of', $link)) { | ||
return false; | ||
} | ||
|
||
return ! in_array(strtolower($link['is_preprint_of']), $this->knownIdentifierValues('is_preprint_of')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace PubPeerFoundation\PublicationDataExtractor\Resources\Extractors; | ||
|
||
interface ProvidesLinksData | ||
{ | ||
public function extractLinksData(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.