Skip to content
Snippets Groups Projects
Commit 3f3110f3 authored by David Maus's avatar David Maus
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
Showing
with 1470 additions and 0 deletions
((nil . ((php-project-name . "HAB RFC4287"))))
# GNU Emacs
*~
\#*
ChangeLog
# Composer
composer.lock
/vendor/
This diff is collapsed.
.PHONY: test
test:
phpunit
HAB RFC4287 – Atom Syndication Format for PHP
=============================================
This source code is Copyright (c) 2017 by Herzog August Bibliothek Wolfenbüttel and released under the terms of the GNU
General Public License 3 or higher.
{
"name": "hab/rfc4287",
"autoload": {
"psr-0": {
"HAB": "src/"
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="vendor/autoload.php" strict="true">
<testsuite name="Unit tests">
<directory suffix="Test.php">tests/unit-tests</directory>
</testsuite>
</phpunit>
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287;
use DOMDocument;
use SimpleXMLElement;
use DateTimeInterface;
use DateTimeImmutable;
/**
* Abstract base class of FeedBuilder and EntryBuilder.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
abstract class Builder
{
/**
* Current container.
*
* @var Model\Container
*/
protected $container;
/**
* Constructor.
*
* @return void
*/
public function __construct ()
{
$this->init();
}
/**
* Initialize builder.
*
* @return void
*/
abstract public function init ();
/**
* Set container property.
*
* @param string $name
* @param Model\VisitableInterface $value
* @return static
*/
public function set ($name, Model\VisitableInterface $value)
{
$this->container[$name] = $value;
return $this;
}
/**
* Return container property.
*
* @param string $name
* @return Model\VisitableInterface|null
*/
public function get ($name)
{
if (isset($this->container[$name])) {
return $this->container[$name];
}
}
/**
* Add a link.
*
* @param string $target
* @param string $relation
* @param string $title
* @param string $type
* @param string $hreflang
* @param string $length
* @return static
*/
public function link ($target, $relation, $title = null, $type = null, $hreflang = null, $length = null)
{
if (!isset($this->container['link'])) {
$this->container['link'] = new Model\VisitableAggregate();
}
$this->container['link']->append(new Model\Link($target, $relation, $title, $type, $hreflang, $length));
return $this;
}
/**
* Add updated timestamp.
*
* @param string|DateTimeInterface $datetime
* @return static
*/
public function updated ($datetime)
{
if (!$datetime instanceof DateTimeInterface) {
$datetime = new DateTimeImmutable($datetime);
}
$this->container['updated'] = new Model\DateConstruct($datetime);
return $this;
}
/**
* Add title.
*
* @param mixed $content
* @param string $type
* @return static
*/
public function title ($content, $type = 'text')
{
$title = $this->makeTextConstruct($content, $type);
$this->container['title'] = $title;
return $this;
}
/**
* Add id.
*
* @param string $id
* @return static
*/
public function id ($id)
{
$this->container['id'] = new Model\Literal($id);
return $this;
}
/**
* Add category.
*
* @param string $term
* @param string $scheme
* @param string $label
* @return static
*/
public function category ($term, $scheme = null, $label = null)
{
if (!isset($this->container['category'])) {
$this->container['category'] = new Model\VisitableAggregate();
}
$this->container['category']->append(new Model\Category($term, $scheme, $label));
return $this;
}
/**
* Add author.
*
* @param string $name
* @param string $email
* @param string $url
* @return static
*/
public function author ($name, $email = null, $url = null)
{
$author = new Model\PersonConstruct($name, $email, $url);
if (!isset($this->container['author'])) {
$this->container['author'] = new Model\VisitableAggregate();
}
$this->container['author']->append($author);
return $this;
}
/**
* Add contributor.
*
* @param string $name
* @param string $email
* @param string $url
* @return static
*/
public function contributor ($name, $email = null, $url = null)
{
$contributor = new Model\PersonConstruct($name, $email, $url);
if (!isset($this->container['contributor'])) {
$this->container['contributor'] = new Model\VisitableAggregate();
}
$this->container['contributor']->append($contributor);
return $this;
}
/**
* Add rights.
*
* @param mixed $rights
* @param string $type
* @return static
*/
public function rights ($rights, $type = 'text')
{
$text = $this->makeTextConstruct($rights, $type);
$this->container['rights'] = $text;
return $this;
}
/**
* Return text construct.
*
* @param mixed $content
* @param string $type
* @param array $attributes
* @return Model\TextConstruct
*/
public function makeTextConstruct ($content, $type)
{
if ($type === 'xhtml' or preg_match('@^[^/]+/(xml|[^+]+\+xml)$@u', $type)) {
$text = new Model\XmlTextConstruct($content, $type);
} else {
$text = new Model\PlainTextConstruct($content, $type);
}
return $text;
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287;
/**
* Entry builder.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class EntryBuilder extends Builder
{
/**
* Feed builder.
*
* @var FeedBuilder
*/
private $feed;
/**
* Constructor.
*
* @param FeedBuilder $feed
* @return void
*/
public function __construct (FeedBuilder $feed)
{
parent::__construct();
$this->feed = $feed;
}
/**
* {@inheritDoc}
*/
public function init ()
{
$this->container = new Model\Entry();
}
/**
* Add content.
*
* @param mixed $content
* @param string $type
* @param string $source
* @return self
*/
public function content ($content, $type = 'text', $source = null)
{
if ($source) {
$text = new Model\OutOfLineContent($source, $type);
} else {
$text = $this->makeTextConstruct($content, $type);
}
$this->container['content'] = $text;
return $this;
}
/**
* Add source.
*
* @param Model\Feed $source
* @return static
*/
public function source (Model\Feed $source)
{
$this->container['source'] = $source;
return $this;
}
/**
* Add summary.
*
* @param mixed $summary
* @param string $type
* @return self
*/
public function summary ($summary, $type = 'text')
{
$text = $this->makeTextConstruct($summary, $type);
$this->container['summary'] = $text;
return $this;
}
/**
* Add current entry to feed.
*
* @return FeedBuilder
*/
public function add ()
{
$this->feed->entry($this->container);
$this->init();
return $this->feed;
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287;
/**
* Feed builder.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class FeedBuilder extends Builder
{
/**
* Entry builder instance.
*
* @var EntryBuilder
*/
private $entries;
/**
* {@inheritDoc}
*/
public function init ()
{
$this->container = new Model\Feed();
}
/**
* Add entry or return entry builder.
*
* @param Entry $entry
* @return static|EntryBuilder
*/
public function entry (Model\Entry $entry = null)
{
if ($entry) {
if (!isset($this->container['entry'])) {
$this->container['entry'] = new Model\VisitableAggregate();
}
$this->container['entry']->append($entry);
if ($entry['updated'] > $this->container['updated']) {
$this->container['updated'] = clone($entry['updated']);
}
return $this;
}
if (!$this->entries) {
$this->entries = new EntryBuilder($this);
}
return $this->entries;
}
/**
* Add generator.
*
* @param string $name
* @param string $version
* @param string $uri
* @return self
*/
public function generator ($name, $version = null, $uri = null)
{
$this->container['generator'] = new Model\Generator($name, $version, $uri);
return $this;
}
/**
* Add icon.
*
* @param string $uri
* @return static
*/
public function icon ($uri)
{
$this->container['icon'] = new Model\Literal($uri);
return $this;
}
/**
* Add logo.
*
* @param string $uri
* @return static
*/
public function logo ($uri)
{
$this->container['logo'] = new Model\Literal($uri);
return $this;
}
/**
* Add subtitle.
*
* @param mixed $subtitle
* @param string $type
* @return self
*/
public function subtitle ($subtitle, $type = 'text')
{
$text = $this->makeTextConstruct($subtitle, $type);
$this->container['subtitle'] = $text;
return $this;
}
/**
* Return current feed.
*
* @return Feed
*/
public function getFeed ()
{
if (!$this->container['updated']) {
$this->updated('now');
}
$this->container->sort();
return $this->container;
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Category.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class Category implements VisitableInterface
{
/**
* Term.
*
* @var string
*/
private $term;
/**
* Scheme.
*
* @var string
*/
private $scheme;
/**
* Label.
*
* @var string
*/
private $label;
/**
* Constructor.
*
* @param string $term
* @param string $scheme
* @param string $label
* @return void
*/
public function __construct ($term, $scheme = null, $label = null)
{
$this->term = $term;
$this->scheme = $scheme;
$this->label = $label;
}
/**
* Return term.
*
* @return string
*/
public function getTerm ()
{
return $this->term;
}
/**
* Return scheme.
*
* @return string|null
*/
public function getScheme ()
{
return $this->scheme;
}
/**
* Return label.
*
* @return string|null
*/
public function getLabel ()
{
return $this->label;
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitCategory($this, $qname);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
use ArrayAccess;
use ArrayIterator;
use IteratorAggregate;
use InvalidArgumentException;
/**
* Atom container.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
abstract class Container implements ArrayAccess, IteratorAggregate
{
/**
* Feed data.
*
* @var array
*/
protected $data;
/**
* Constructor.
*
* @return void
*/
public function __construct ()
{
$this->data = array();
}
/**
* {@inheritDoc}
*/
public function offsetGet ($index)
{
if (array_key_exists($index, $this->data)) {
return $this->data[$index];
}
}
/**
* {@inheritDoc}
*/
public function offsetSet ($index, $value)
{
if (!$value instanceof VisitableInterface) {
throw new InvalidArgumentException(sprintf('Feed element must implement %s', VisitableInterface::class));
}
$this->data[$index] = $value;
}
/**
* {@inheritDoc}
*/
public function offsetExists ($index)
{
return array_key_exists($index, $this->data);
}
/**
* {@inheritDoc}
*/
public function offsetUnset ($index)
{
unset($this->data[$index]);
}
/**
* {@inheritDoc}
*/
public function getIterator ()
{
return new ArrayIterator($this->data);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
use DateTimeInterface;
use DateTime;
/**
* Atom date construct.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class DateConstruct implements VisitableInterface
{
/**
* Datetime instance.
*
* @var DateTimeInterface
*/
private $datetime;
/**
* Constructor.
*
* @param DateTimeInterface $datetime
* @return void
*/
public function __construct (DateTimeInterface $datetime)
{
$this->datetime = $datetime;
}
/**
* Format the datetime object.
*
* @param string $format
* @return string
*/
public function format ($format)
{
return $this->datetime->format($format);
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitDateConstruct($this, $qname);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Entry.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class Entry extends Container implements VisitableInterface
{
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitEntry($this, 'entry');
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Atom Feed.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class Feed extends Container implements VisitableInterface
{
/**
* Sort feed elements.
*
* @return void
*/
public function sort ()
{
uksort($this->data, array($this, 'compareQNames'));
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitFeed($this, $qname);
}
/**
* Comparism function for {@see self::sort()}.
*
* @param string $qname_a
* @param string $qname_b
* @return integer
*/
public function compareQNames ($qname_a, $qname_b)
{
if ($qname_a === 'entry') {
return 1;
}
return 0;
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Generator.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class Generator implements VisitableInterface
{
/**
* URI.
*
* @var string
*/
private $uri;
/**
* Version.
*
* @var string
*/
private $version;
/**
* Name.
*
* @var string
*/
private $name;
/**
* Constructor.
*
* @param string $name
* @param string $version
* @param string $uri
* @return void
*/
public function __construct ($name, $version = null, $uri = null)
{
$this->name = $name;
$this->version = $version;
$this->uri = $uri;
}
/**
* Return name.
*
* @return string
*/
public function getName ()
{
return $this->name;
}
/**
* Return version.
*
* @return string|null
*/
public function getVersion ()
{
return $this->version;
}
/**
* Return uri.
*
* @return string|null
*/
public function getUri ()
{
return $this->uri;
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitGenerator($this, $qname);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Atom Link.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class Link implements VisitableInterface
{
/**
* Link target.
*
* @var string
*/
private $target;
/**
* Link relation.
*
* @var string
*/
private $relation;
/**
* Link title.
*
* @var string
*/
private $title;
/**
* Link target language.
*
* @var string
*/
private $language;
/**
* Link target type.
*
* @var string
*/
private $type;
/**
* Link target size.
*
* @var string
*/
private $length;
/**
* Constructor.
*
* @param string $target
* @param string $relation
* @param string
* @return void
*/
public function __construct ($target, $relation, $title = null, $type = null, $language = null, $length)
{
$this->target = $target;
$this->relation = $relation;
$this->title = $title;
$this->language = $language;
$this->type = $type;
$this->length = $length;
}
/**
* Return target.
*
* @return string
*/
public function getTarget ()
{
return $this->target;
}
/**
* Return relation.
*
* @return string
*/
public function getRelation ()
{
return $this->relation;
}
/**
* Return title.
*
* @return string|null
*/
public function getTitle ()
{
return $this->title;
}
/**
* Return target language.
*
* @return string|null
*/
public function getTargetLanguage ()
{
return $this->language;
}
/**
* Return type.
*
* @return string|null
*/
public function getTargetType ()
{
return $this->type;
}
/**
* Return length.
*
* @return string|null
*/
public function getTargetLength ()
{
return $this->length;
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitLink($this, $qname);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Literal value.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class Literal implements VisitableInterface
{
/**
* Value.
*
* @var string
*/
private $value;
/**
* Constructor.
*
* @param string $value
* @return void
*/
public function __construct ($value)
{
$this->value = $value;
}
/**
* Return value.
*
* @return string
*/
public function getValue ()
{
return $this->value;
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitLiteral($this, $qname);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Out of line content.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class OutOfLineContent implements VisitableInterface
{
/**
* Type.
*
* @var string
*/
private $type;
/**
* Source.
*
* @var string
*/
private $source;
/**
* Constructor.
*
* @param string $source
* @param string $type
* @return void
*/
public function __construct ($source, $type)
{
$this->type = $type;
$this->source = $source;
}
/**
* Return type.
*
* @return string
*/
public function getType ()
{
return $this->type;
}
/**
* Return source.
*
* @return string
*/
public function getSource ()
{
return $this->source;
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitOutOfLineContent($this, $qname);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB RFC4287.
*
* HAB RFC4287 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB RFC4287 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HAB RFC4287. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\RFC4287\Model;
/**
* Person construct.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class PersonConstruct implements VisitableInterface
{
/**
* Name.
*
* @var string
*/
private $name;
/**
* Email address.
*
* @var string
*/
private $email;
/**
* Uri.
*
* @var string
*/
private $uri;
/**
* Construct.
*
* @param string $name
* @param string $email
* @param string $uri
* @return void
*/
public function __construct ($name = null, $email = null, $uri = null)
{
$this->email = $email;
$this->name = $name;
$this->uri = $uri;
}
/**
* Return name.
*
* @return string
*/
public function getName ()
{
return $this->name;
}
/**
* Return email.
*
* @return string
*/
public function getEmail ()
{
return $this->email;
}
/**
* Return uri.
*
* @return string
*/
public function getUri ()
{
return $this->uri;
}
/**
* {@inheritDoc}
*/
public function accept (VisitorInterface $visitor, $qname)
{
$visitor->visitPersonConstruct($this, $qname);
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment