for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* citeproc-php
*
* @link http://github.com/seboettg/citeproc-php for the source repository
* @copyright Copyright (c) 2017 Sebastian Böttger.
* @license https://opensource.org/licenses/MIT
*/
namespace Seboettg\CiteProc\Root;
use SimpleXMLElement;
use stdClass;
class Info
{
/**
* @var string
private $title;
private $id;
* @var array
private $authors;
private $links;
public static function factory(SimpleXMLElement $node): Info
$authors = [];
$links = [];
$id = null;
$title = null;
foreach ($node->children() as $child) {
switch ($child->getName()) {
case 'author':
case 'contributor':
$author = new stdClass();
/** @var SimpleXMLElement $authorNode */
foreach ($child->children() as $authorNode) {
$author->{$authorNode->getName()} = (string) $authorNode;
}
$authors[] = $author;
break;
case 'link':
$links[] = (string) $child->attributes()['href'];
case 'id':
$id = (string) $child;
case 'title':
$title = (string) $child;
return new Info($id, $title, $authors, $links);
public function __construct(?string $id, ?string $title, array $authors, array $links)
$this->id = $id;
$this->title = $title;
$this->authors = $authors;
$this->links = $links;
* @return string
public function getTitle(): ?string
return $this->title;
public function getId(): ?string
return $this->id;
* @return array
public function getAuthors(): array
return $this->authors;
public function getLinks(): array
return $this->links;