for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PubPeerFoundation\PublicationDataExtractor\Identifiers;
use PubPeerFoundation\PublicationDataExtractor\Exceptions\UnknownIdentifierException;
class IdentifierResolver
{
/**
* List of available Identifiers.
*
* @var array
*/
protected $identifiers = [
BioArxiv::class,
Figshare::class,
Doi::class,
Arxiv::class,
Pubmed::class,
];
* The query string.
* @var string
private $queryString;
* Identifier constructor.
* @param string $queryString
public function __construct(string $queryString)
$this->queryString = $queryString;
}
* Resolves the Identifier;.
* @return Identifier
* @throws UnknownIdentifierException
public function handle()
foreach ($this->identifiers as $identifierClass) {
$identifier = new $identifierClass($this->queryString);
if ($identifier->isValid()) {
return $this->validIdentifier = $identifier;
validIdentifier
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
throw new UnknownIdentifierException();
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: