first commit
This commit is contained in:
@@ -0,0 +1,326 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
use WindowsAzure\Common\Internal\Atom\AtomLink;
|
||||
|
||||
/**
|
||||
* The base class of ATOM library.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class AtomBase
|
||||
{
|
||||
/**
|
||||
* The attributes of the feed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes;
|
||||
|
||||
/**
|
||||
* Creates an ATOM base object with default parameters.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->attributes = array();
|
||||
$atomlink = new AtomLink();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attributes of the ATOM class.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attributes of the ATOM class.
|
||||
*
|
||||
* @param array $attributes The attributes of the array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setAttributes($attributes)
|
||||
{
|
||||
Validate::isArray($attributes, 'attributes');
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an attribute to the ATOM object instance.
|
||||
*
|
||||
* @param string $attributeKey The key of the attribute.
|
||||
* @param mixed $attributeValue The value of the attribute.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setAttribute($attributeKey, $attributeValue)
|
||||
{
|
||||
$this->attributes[$attributeKey] = $attributeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an attribute with a specified attribute key.
|
||||
*
|
||||
* @param string $attributeKey The key of the attribute.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function getAttribute($attributeKey)
|
||||
{
|
||||
return $this->attributes[$attributeKey];
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes author node.
|
||||
*
|
||||
* @param array $xmlWriter The XML writer.
|
||||
* @param array $itemArray An array of item to write.
|
||||
* @param array $elementName The name of the element.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function writeArrayItem($xmlWriter, $itemArray, $elementName)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
Validate::isArray($itemArray, 'itemArray');
|
||||
Validate::isString($elementName, 'elementName');
|
||||
|
||||
foreach ($itemArray as $itemInstance) {
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
$elementName,
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
$itemInstance->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes author node.
|
||||
*
|
||||
* @param array $xmlArray An array of simple xml elements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processAuthorNode($xmlArray)
|
||||
{
|
||||
$author = array();
|
||||
$authorItem = $xmlArray[Resources::AUTHOR];
|
||||
|
||||
if (is_array($authorItem)) {
|
||||
foreach ($xmlArray[Resources::AUTHOR] as $authorXmlInstance) {
|
||||
$authorInstance = new Person();
|
||||
$authorInstance->parseXml($authorXmlInstance->asXML());
|
||||
$author[] = $authorInstance;
|
||||
}
|
||||
} else {
|
||||
$authorInstance = new Person();
|
||||
$authorInstance->parseXml($authorItem->asXML());
|
||||
$author[] = $authorInstance;
|
||||
}
|
||||
return $author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes entry node.
|
||||
*
|
||||
* @param array $xmlArray An array of simple xml elements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processEntryNode($xmlArray)
|
||||
{
|
||||
$entry = array();
|
||||
$entryItem = $xmlArray[Resources::ENTRY];
|
||||
|
||||
if (is_array($entryItem)) {
|
||||
foreach ($xmlArray[Resources::ENTRY] as $entryXmlInstance) {
|
||||
$entryInstance = new Entry();
|
||||
$entryInstance->fromXml($entryXmlInstance);
|
||||
$entry[] = $entryInstance;
|
||||
}
|
||||
} else {
|
||||
$entryInstance = new Entry();
|
||||
$entryInstance->fromXml($entryItem);
|
||||
$entry[] = $entryInstance;
|
||||
}
|
||||
return $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes category node.
|
||||
*
|
||||
* @param array $xmlArray An array of simple xml elements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processCategoryNode($xmlArray)
|
||||
{
|
||||
$category = array();
|
||||
$categoryItem = $xmlArray[Resources::CATEGORY];
|
||||
|
||||
if (is_array($categoryItem)) {
|
||||
foreach ($xmlArray[Resources::CATEGORY] as $categoryXmlInstance) {
|
||||
$categoryInstance = new Category();
|
||||
$categoryInstance->parseXml($categoryXmlInstance->asXML());
|
||||
$category[] = $categoryInstance;
|
||||
}
|
||||
} else {
|
||||
$categoryInstance = new Category();
|
||||
$categoryInstance->parseXml($categoryItem->asXML());
|
||||
$category[] = $categoryInstance;
|
||||
}
|
||||
return $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes contributor node.
|
||||
*
|
||||
* @param array $xmlArray An array of simple xml elements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processContributorNode($xmlArray)
|
||||
{
|
||||
$category = array();
|
||||
$contributorItem = $xmlArray[Resources::CONTRIBUTOR];
|
||||
|
||||
if (is_array($contributorItem)) {
|
||||
foreach ($xmlArray[Resources::CONTRIBUTOR] as $contributorXmlInstance) {
|
||||
$contributorInstance = new Person();
|
||||
$contributorInstance->parseXml($contributorXmlInstance->asXML());
|
||||
$contributor[] = $contributorInstance;
|
||||
}
|
||||
} elseif (is_string($contributorItem)) {
|
||||
$contributorInstance = new Person();
|
||||
$contributorInstance->setName((string)$contributorItem);
|
||||
$contributor[] = $contributorInstance;
|
||||
} else {
|
||||
$contributorInstance = new Person();
|
||||
$contributorInstance->parseXml($contributorItem->asXML());
|
||||
$contributor[] = $contributorInstance;
|
||||
}
|
||||
return $contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes link node.
|
||||
*
|
||||
* @param array $xmlArray An array of simple xml elements.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function processLinkNode($xmlArray)
|
||||
{
|
||||
$link = array();
|
||||
$linkValue = $xmlArray[Resources::LINK];
|
||||
|
||||
if (is_array($linkValue)) {
|
||||
foreach ($xmlArray[Resources::LINK] as $linkValueInstance) {
|
||||
$linkInstance = new AtomLink();
|
||||
$linkInstance->parseXml($linkValueInstance->asXML());
|
||||
$link[] = $linkInstance;
|
||||
}
|
||||
} else {
|
||||
$linkInstance = new AtomLink();
|
||||
$linkInstance->parseXml($linkValue->asXML());
|
||||
$link[] = $linkInstance;
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an optional attribute for ATOM.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
* @param string $attributeName The name of the attribute.
|
||||
* @param mixed $attributeValue The value of the attribute.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
protected function writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
$attributeName,
|
||||
$attributeValue
|
||||
) {
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
Validate::isString($attributeName, 'attributeName');
|
||||
|
||||
if (!empty($attributeValue)) {
|
||||
$xmlWriter->writeAttribute(
|
||||
$attributeName,
|
||||
$attributeValue
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the optional elements namespaces.
|
||||
*
|
||||
* @param \XmlWriter $xmlWriter The XML writer.
|
||||
* @param string $prefix The prefix.
|
||||
* @param string $elementName The element name.
|
||||
* @param string $namespace The namespace name.
|
||||
* @param string $elementValue The element value.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
protected function writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
$prefix,
|
||||
$elementName,
|
||||
$namespace,
|
||||
$elementValue
|
||||
) {
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
Validate::isString($elementName, 'elementName');
|
||||
|
||||
if (!empty($elementValue)) {
|
||||
$xmlWriter->writeElementNS(
|
||||
$prefix,
|
||||
$elementName,
|
||||
$namespace,
|
||||
$elementValue
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,343 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
use WindowsAzure\Common\Internal\Utilities;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
|
||||
/**
|
||||
* This link defines a reference from an entry or feed to a Web resource.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class AtomLink extends AtomBase
|
||||
{
|
||||
/**
|
||||
* The undefined content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $undefinedContent;
|
||||
|
||||
/**
|
||||
* The HREF of the link.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $href;
|
||||
|
||||
/**
|
||||
* The rel attribute of the link.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rel;
|
||||
|
||||
/**
|
||||
* The media type of the link.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* The language of HREF.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $hreflang;
|
||||
|
||||
/**
|
||||
* The titile of the link.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* The length of the link.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $length;
|
||||
|
||||
/**
|
||||
* Creates a AtomLink instance with specified text.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse an ATOM Link xml.
|
||||
*
|
||||
* @param string $xmlString an XML based string of ATOM Link.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
Validate::notNull($xmlString, 'xmlString');
|
||||
Validate::isString($xmlString, 'xmlString');
|
||||
$atomLinkXml = simplexml_load_string($xmlString);
|
||||
$attributes = $atomLinkXml->attributes();
|
||||
|
||||
if (!empty($attributes['href'])) {
|
||||
$this->href = (string)$attributes['href'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['rel'])) {
|
||||
$this->rel = (string)$attributes['rel'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['type'])) {
|
||||
$this->type = (string)$attributes['type'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['hreflang'])) {
|
||||
$this->hreflang = (string)$attributes['hreflang'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['title'])) {
|
||||
$this->title = (string)$attributes['title'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['length'])) {
|
||||
$this->length = (int)$attributes['length'];
|
||||
}
|
||||
|
||||
$undefinedContent = (string)$atomLinkXml;
|
||||
if (empty($undefinedContent)) {
|
||||
$this->undefinedContent = null;
|
||||
} else {
|
||||
$this->undefinedContent = (string)$atomLinkXml;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the href of the link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHref()
|
||||
{
|
||||
return $this->href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the href of the link.
|
||||
*
|
||||
* @param string $href The href of the link.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setHref($href)
|
||||
{
|
||||
$this->href = $href;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rel of the atomLink.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRel()
|
||||
{
|
||||
return $this->rel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rel of the link.
|
||||
*
|
||||
* @param string $rel The rel of the atomLink.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setRel($rel)
|
||||
{
|
||||
$this->rel = $rel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the link.
|
||||
*
|
||||
* @param string $type The type of the link.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the language of the href.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getHrefLang()
|
||||
{
|
||||
return $this->hrefLang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the language of the href.
|
||||
*
|
||||
* @param string $hrefLang The language of the href.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setHrefLang($hrefLang)
|
||||
{
|
||||
$this->hrefLang = $hrefLang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title of the link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title of the link.
|
||||
*
|
||||
* @param string $title The title of the link.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the length of the link.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLength()
|
||||
{
|
||||
return $this->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the length of the link.
|
||||
*
|
||||
* @param string $length The length of the link.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLength($length)
|
||||
{
|
||||
$this->length = $length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the undefined content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUndefinedContent()
|
||||
{
|
||||
return $this->undefinedContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the undefined content.
|
||||
*
|
||||
* @param string $undefinedContent The undefined content.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUndefinedContent($undefinedContent)
|
||||
{
|
||||
$this->undefinedContent = $undefinedContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the ATOM link item.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The xml writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
Resources::LINK,
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the inner XML representing the ATOM link item.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The xml writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
|
||||
$this->writeOptionalAttribute($xmlWriter, 'href', $this->href);
|
||||
$this->writeOptionalAttribute($xmlWriter, 'rel', $this->rel);
|
||||
$this->writeOptionalAttribute($xmlWriter, 'type', $this->type);
|
||||
$this->writeOptionalAttribute($xmlWriter, 'hreflang', $this->hreflang);
|
||||
$this->writeOptionalAttribute($xmlWriter, 'title', $this->title);
|
||||
$this->writeOptionalAttribute($xmlWriter, 'length', $this->length);
|
||||
|
||||
if (!empty($this->undefinedContent)) {
|
||||
$xmlWriter->writeRaw($this->undefinedContent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,253 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
use WindowsAzure\Common\Internal\Utilities;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
|
||||
/**
|
||||
* The category class of the ATOM standard.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Category extends AtomBase
|
||||
{
|
||||
/**
|
||||
* The term of the category.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $term;
|
||||
|
||||
/**
|
||||
* The scheme of the category.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $scheme;
|
||||
|
||||
/**
|
||||
* The label of the category.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $label;
|
||||
|
||||
/**
|
||||
* The undefined content of the category.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $undefinedContent;
|
||||
|
||||
/**
|
||||
* Creates a Category instance with specified text.
|
||||
*
|
||||
* @param string $undefinedContent The undefined content of the category.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function __construct($undefinedContent = Resources::EMPTY_STRING)
|
||||
{
|
||||
$this->undefinedContent = $undefinedContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ATOM Category instance with specified xml string.
|
||||
*
|
||||
* @param string $xmlString an XML based string of ATOM CONTENT.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
Validate::notNull($xmlString, 'xmlString');
|
||||
Validate::isString($xmlString, 'xmlString');
|
||||
$categoryXml = simplexml_load_string($xmlString);
|
||||
$attributes = $categoryXml->attributes();
|
||||
if (!empty($attributes['term'])) {
|
||||
$this->term = (string)$attributes['term'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['scheme'])) {
|
||||
$this->scheme = (string)$attributes['scheme'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['label'])) {
|
||||
$this->label = (string)$attributes['label'];
|
||||
}
|
||||
|
||||
$this->undefinedContent =(string)$categoryXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the term of the category.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTerm()
|
||||
{
|
||||
return $this->term;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the term of the category.
|
||||
*
|
||||
* @param string $term The term of the category.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setTerm($term)
|
||||
{
|
||||
$this->term = $term;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scheme of the category.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getScheme()
|
||||
{
|
||||
return $this->scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the scheme of the category.
|
||||
*
|
||||
* @param string $scheme The scheme of the category.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setScheme($scheme)
|
||||
{
|
||||
$this->scheme = $scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the label of the category.
|
||||
*
|
||||
* @return string The label.
|
||||
*/
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label of the category.
|
||||
*
|
||||
* @param string $label The label of the category.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLabel($label)
|
||||
{
|
||||
$this->label = $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the undefined content of the category.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUndefinedContent()
|
||||
{
|
||||
return $this->undefinedContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the undefined content of the category.
|
||||
*
|
||||
* @param string $undefinedContent The undefined content of the category.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUndefinedContent($undefinedContent)
|
||||
{
|
||||
$this->undefinedContent = $undefinedContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the category.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
'category',
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the category.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$this->writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
'term',
|
||||
$this->term
|
||||
);
|
||||
|
||||
$this->writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
'scheme',
|
||||
$this->scheme
|
||||
);
|
||||
|
||||
$this->writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
'label',
|
||||
$this->label
|
||||
);
|
||||
|
||||
if (!empty($this->undefinedContent)) {
|
||||
$xmlWriter->WriteRaw($this->undefinedContent);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
use WindowsAzure\Common\Internal\Utilities;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
use WindowsAzure\Common\Internal\Atom\AtomProperties;
|
||||
/**
|
||||
* The content class of ATOM standard.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Content extends AtomBase
|
||||
{
|
||||
/**
|
||||
* The text of the content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
/**
|
||||
* The type of the content.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* Source XML object
|
||||
*
|
||||
* @var \SimpleXMLElement
|
||||
*/
|
||||
protected $xml;
|
||||
|
||||
/**
|
||||
* Creates a Content instance with specified text.
|
||||
*
|
||||
* @param string $text The text of the content.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function __construct($text = null)
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ATOM CONTENT instance with specified xml string.
|
||||
*
|
||||
* @param string $xmlString an XML based string of ATOM CONTENT.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
Validate::notNull($xmlString, 'xmlString');
|
||||
Validate::isString($xmlString, 'xmlString');
|
||||
|
||||
$this->fromXml(simplexml_load_string($xmlString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ATOM CONTENT instance with specified simpleXML object
|
||||
*
|
||||
* @param \SimpleXMLElement $contentXml xml element of ATOM CONTENT
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function fromXml($contentXml)
|
||||
{
|
||||
Validate::notNull($contentXml, 'contentXml');
|
||||
Validate::isA($contentXml, '\SimpleXMLElement', 'contentXml');
|
||||
|
||||
$attributes = $contentXml->attributes();
|
||||
|
||||
if (!empty($attributes['type'])) {
|
||||
$this->content = (string)$attributes['type'];
|
||||
}
|
||||
|
||||
$text = '';
|
||||
foreach ($contentXml->children() as $child) {
|
||||
$text .= $child->asXML();
|
||||
}
|
||||
|
||||
$this->text = $text;
|
||||
|
||||
$this->xml = $contentXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text of the content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of the content.
|
||||
*
|
||||
* @param string $text The text of the content.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the xml object of the content.
|
||||
*
|
||||
* @return \SimpleXMLElement
|
||||
*/
|
||||
public function getXml()
|
||||
{
|
||||
return $this->xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of the content.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the type of the content.
|
||||
*
|
||||
* @param string $type The type of the content.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the content.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
'content',
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
|
||||
$this->writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
'type',
|
||||
$this->type
|
||||
);
|
||||
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an inner XML representing the content.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->writeRaw($this->text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,645 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Utilities;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
|
||||
/**
|
||||
* The Entry class of ATOM standard.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Entry extends AtomBase
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
/**
|
||||
* The author of the entry.
|
||||
*
|
||||
* @var Person
|
||||
*/
|
||||
protected $author;
|
||||
|
||||
/**
|
||||
* The category of the entry.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* The content of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $content;
|
||||
|
||||
/**
|
||||
* The contributor of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $contributor;
|
||||
|
||||
/**
|
||||
* An unqiue ID representing the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The link of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* Is the entry published.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $published;
|
||||
|
||||
/**
|
||||
* The copy right of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rights;
|
||||
|
||||
/**
|
||||
* The source of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $source;
|
||||
|
||||
/**
|
||||
* The summary of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $summary;
|
||||
|
||||
/**
|
||||
* The title of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* Is the entry updated.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $updated;
|
||||
|
||||
/**
|
||||
* The extension element of the entry.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $extensionElement;
|
||||
|
||||
/**
|
||||
* Creates an ATOM Entry instance with default parameters.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->attributes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the properties of an ATOM Entry instance with specified XML..
|
||||
*
|
||||
* @param string $xmlString A string representing an ATOM entry instance.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
Validate::notNull($xmlString, 'xmlString');
|
||||
|
||||
$this->fromXml(simplexml_load_string($xmlString));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ATOM ENTRY instance with specified simpleXML object
|
||||
*
|
||||
* @param \SimpleXMLElement $entryXml xml element of ATOM ENTRY
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function fromXml($entryXml) {
|
||||
Validate::notNull($entryXml, 'entryXml');
|
||||
Validate::isA($entryXml, '\SimpleXMLElement', 'entryXml');
|
||||
|
||||
$this->attributes = (array)$entryXml->attributes();
|
||||
$entryArray = (array)$entryXml;
|
||||
|
||||
if (array_key_exists(Resources::AUTHOR, $entryArray)) {
|
||||
$this->author = $this->processAuthorNode($entryArray);
|
||||
}
|
||||
|
||||
if (array_key_exists(Resources::CATEGORY, $entryArray)) {
|
||||
$this->category = $this->processCategoryNode($entryArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('content', $entryArray)) {
|
||||
$content = new Content();
|
||||
$content->fromXml($entryArray['content']);
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
if (array_key_exists(Resources::CONTRIBUTOR, $entryArray)) {
|
||||
$this->contributor = $this->processContributorNode($entryArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('id', $entryArray)) {
|
||||
$this->id = (string)$entryArray['id'];
|
||||
}
|
||||
|
||||
if (array_key_exists(Resources::LINK, $entryArray)) {
|
||||
$this->link = $this->processLinkNode($entryArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('published', $entryArray)) {
|
||||
$this->published = $entryArray['published'];
|
||||
}
|
||||
|
||||
if (array_key_exists('rights', $entryArray)) {
|
||||
$this->rights = $entryArray['rights'];
|
||||
}
|
||||
|
||||
if (array_key_exists('source', $entryArray)) {
|
||||
$source = new Source();
|
||||
$source->parseXml($entryArray['source']->asXML());
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
if (array_key_exists('title', $entryArray)) {
|
||||
$this->title = $entryArray['title'];
|
||||
}
|
||||
|
||||
if (array_key_exists('updated', $entryArray)) {
|
||||
$this->updated = \DateTime::createFromFormat(
|
||||
\DateTime::ATOM,
|
||||
(string)$entryArray['updated']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author of the entry.
|
||||
*
|
||||
* @return Person
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author of the entry.
|
||||
*
|
||||
* @param Person $author The author of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
$this->author = $author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the category.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category.
|
||||
*
|
||||
* @param string $category The category of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setCategory($category)
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the content.
|
||||
*
|
||||
* @return Content.
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content.
|
||||
*
|
||||
* @param Content $content Sets the content of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the contributor.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContributor()
|
||||
{
|
||||
return $this->contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the contributor.
|
||||
*
|
||||
* @param string $contributor The contributor of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setContributor($contributor)
|
||||
{
|
||||
$this->contributor = $contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of the entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the entry.
|
||||
*
|
||||
* @param string $id The id of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link of the entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link of the entry.
|
||||
*
|
||||
* @param string $link The link of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets published of the entry.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function getPublished()
|
||||
{
|
||||
return $this->published;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets published of the entry.
|
||||
*
|
||||
* @param boolean $published Is the entry published.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setPublished($published)
|
||||
{
|
||||
$this->published = $published;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rights of the entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRights()
|
||||
{
|
||||
return $this->rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rights of the entry.
|
||||
*
|
||||
* @param string $rights The rights of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setRights($rights)
|
||||
{
|
||||
$this->rights = $rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the source of the entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSource()
|
||||
{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the source of the entry.
|
||||
*
|
||||
* @param string $source The source of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setSource($source)
|
||||
{
|
||||
$this->source = $source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the summary of the entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSummary()
|
||||
{
|
||||
return $this->summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the summary of the entry.
|
||||
*
|
||||
* @param string $summary The summary of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setSummary($summary)
|
||||
{
|
||||
$this->summary = $summary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title of the entry.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title of the entry.
|
||||
*
|
||||
* @param string $title The title of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets updated.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getUpdated()
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets updated
|
||||
*
|
||||
* @param \DateTime $updated updated.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUpdated($updated)
|
||||
{
|
||||
$this->updated = $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets extension element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtensionElement()
|
||||
{
|
||||
return $this->extensionElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets extension element.
|
||||
*
|
||||
* @param string $extensionElement The extension element of the entry.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setExtensionElement($extensionElement)
|
||||
{
|
||||
$this->extensionElement = $extensionElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a inner XML string representing the entry.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
Resources::ENTRY,
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a inner XML string representing the entry.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
if (!is_null($this->attributes)) {
|
||||
if (is_array($this->attributes)) {
|
||||
foreach (
|
||||
$this->attributes
|
||||
as $attributeName => $attributeValue
|
||||
) {
|
||||
$xmlWriter->writeAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($this->author)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->author,
|
||||
Resources::AUTHOR
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->category)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->category,
|
||||
Resources::CATEGORY
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->content)) {
|
||||
$this->content->writeXml($xmlWriter);
|
||||
}
|
||||
|
||||
if (!is_null($this->contributor)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->contributor,
|
||||
Resources::CONTRIBUTOR
|
||||
);
|
||||
}
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'id',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->id
|
||||
);
|
||||
|
||||
if (!is_null($this->link)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->link,
|
||||
Resources::LINK
|
||||
);
|
||||
}
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'published',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->published
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'rights',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->rights
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'source',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->source
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'summary',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->summary
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'title',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->title
|
||||
);
|
||||
|
||||
if (!is_null($this->updated)) {
|
||||
$xmlWriter->writeElementNS(
|
||||
'atom',
|
||||
'updated',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->updated->format(\DateTime::ATOM)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
@@ -0,0 +1,730 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
|
||||
/**
|
||||
* The feed class of ATOM library.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Feed extends AtomBase
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
/**
|
||||
* The entry of the feed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $entry;
|
||||
|
||||
/**
|
||||
* the author of the feed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $author;
|
||||
|
||||
/**
|
||||
* The category of the feed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* The contributor of the feed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $contributor;
|
||||
|
||||
/**
|
||||
* The generator of the feed.
|
||||
*
|
||||
* @var Generator
|
||||
*/
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* The icon of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $icon;
|
||||
|
||||
/**
|
||||
* The ID of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The link of the feed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* The logo of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $logo;
|
||||
|
||||
/**
|
||||
* The rights of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rights;
|
||||
|
||||
/**
|
||||
* The subtitle of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $subtitle;
|
||||
|
||||
/**
|
||||
* The title of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* The update of the feed.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $updated;
|
||||
|
||||
/**
|
||||
* The extension element of the feed.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $extensionElement;
|
||||
|
||||
/**
|
||||
* Creates an ATOM FEED object with default parameters.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->attributes = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a feed object with specified XML string.
|
||||
*
|
||||
* @param string $xmlString An XML string representing the feed object.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
$feedXml = simplexml_load_string($xmlString);
|
||||
$attributes = $feedXml->attributes();
|
||||
$feedArray = (array)$feedXml;
|
||||
if (!empty($attributes)) {
|
||||
$this->attributes = (array)$attributes;
|
||||
}
|
||||
|
||||
if (array_key_exists('author', $feedArray)) {
|
||||
$this->author = $this->processAuthorNode($feedArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('entry', $feedArray)) {
|
||||
$this->entry = $this->processEntryNode($feedArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('category', $feedArray)) {
|
||||
$this->category = $this->processCategoryNode($feedArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('contributor', $feedArray)) {
|
||||
$this->contributor = $this->processContributorNode($feedArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('generator', $feedArray)) {
|
||||
$generator = new Generator();
|
||||
$generatorValue = $feedArray['generator'];
|
||||
if (is_string($generatorValue)) {
|
||||
$generator->setText($generatorValue);
|
||||
} else {
|
||||
$generator->parseXml($generatorValue->asXML());
|
||||
}
|
||||
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
if (array_key_exists('icon', $feedArray)) {
|
||||
$this->icon = (string)$feedArray['icon'];
|
||||
}
|
||||
|
||||
if (array_key_exists('id', $feedArray)) {
|
||||
$this->id = (string)$feedArray['id'];
|
||||
}
|
||||
|
||||
if (array_key_exists('link', $feedArray)) {
|
||||
$this->link = $this->processLinkNode($feedArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('logo', $feedArray)) {
|
||||
$this->logo = (string)$feedArray['logo'];
|
||||
}
|
||||
|
||||
if (array_key_exists('rights', $feedArray)) {
|
||||
$this->rights = (string)$feedArray['rights'];
|
||||
}
|
||||
|
||||
if (array_key_exists('subtitle', $feedArray)) {
|
||||
$this->subtitle = (string)$feedArray['subtitle'];
|
||||
}
|
||||
|
||||
if (array_key_exists('title', $feedArray)) {
|
||||
$this->title = (string)$feedArray['title'];
|
||||
}
|
||||
|
||||
if (array_key_exists('updated', $feedArray)) {
|
||||
$this->updated = \DateTime::createFromFormat(
|
||||
\DateTime::ATOM,
|
||||
(string)$feedArray['updated']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attributes of the feed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAttributes()
|
||||
{
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attributes of the feed.
|
||||
*
|
||||
* @param array $attributes The attributes of the array.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function setAttributes($attributes)
|
||||
{
|
||||
Validate::isArray($attributes, 'attributes');
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an attribute to the feed object instance.
|
||||
*
|
||||
* @param string $attributeKey The key of the attribute.
|
||||
* @param mixed $attributeValue The value of the attribute.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function addAttribute($attributeKey, $attributeValue)
|
||||
{
|
||||
$this->attributes[$attributeKey] = $attributeValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author of the feed.
|
||||
*
|
||||
* @return Person
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author of the feed.
|
||||
*
|
||||
* @param Person $author The author of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
Validate::isArray($author, 'author');
|
||||
$person = new Person();
|
||||
foreach ($author as $authorInstance) {
|
||||
Validate::isInstanceOf($authorInstance, $person, 'author');
|
||||
}
|
||||
$this->author = $author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the category of the feed.
|
||||
*
|
||||
* @return Category
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category of the feed.
|
||||
*
|
||||
* @param Category $category The category of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setCategory($category)
|
||||
{
|
||||
Validate::isArray($category, 'category');
|
||||
$categoryClassInstance = new Category();
|
||||
foreach ($category as $categoryInstance) {
|
||||
Validate::isInstanceOf(
|
||||
$categoryInstance,
|
||||
$categoryClassInstance,
|
||||
'category'
|
||||
);
|
||||
}
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contributor.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getContributor()
|
||||
{
|
||||
return $this->contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contributor.
|
||||
*
|
||||
* @param string $contributor The contributor of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setContributor($contributor)
|
||||
{
|
||||
Validate::isArray($contributor, 'contributor');
|
||||
$person = new Person();
|
||||
foreach ($contributor as $contributorInstance) {
|
||||
Validate::isInstanceOf($contributorInstance, $person, 'contributor');
|
||||
}
|
||||
$this->contributor = $contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets generator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
return $this->generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the generator.
|
||||
*
|
||||
* @param string $generator Sets the generator of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setGenerator($generator)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon of the feed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon of the feed.
|
||||
*
|
||||
* @param string $icon The icon of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setIcon($icon)
|
||||
{
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of the feed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the feed.
|
||||
*
|
||||
* @param string $id The ID of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link of the feed.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link of the feed.
|
||||
*
|
||||
* @param array $link The link of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
Validate::isArray($link, 'link');
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logo of the feed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLogo()
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logo of the feed.
|
||||
*
|
||||
* @param string $logo The logo of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLogo($logo)
|
||||
{
|
||||
$this->logo = $logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rights of the feed.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRights()
|
||||
{
|
||||
return $this->rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rights of the feed.
|
||||
*
|
||||
* @param string $rights The rights of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setRights($rights)
|
||||
{
|
||||
$this->rights = $rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sub title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubtitle()
|
||||
{
|
||||
return $this->subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sub title of the feed.
|
||||
*
|
||||
* @param string $subtitle Sets the sub title of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setSubtitle($subtitle)
|
||||
{
|
||||
$this->subtitle = $subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title of the feed.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title of the feed.
|
||||
*
|
||||
* @param string $title The title of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the updated.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getUpdated()
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the updated.
|
||||
*
|
||||
* @param \DateTime $updated updated
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUpdated($updated)
|
||||
{
|
||||
Validate::isInstanceOf($updated, new \DateTime(), 'updated');
|
||||
$this->updated = $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extension element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtensionElement()
|
||||
{
|
||||
return $this->extensionElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the extension element.
|
||||
*
|
||||
* @param string $extensionElement The extension element.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setExtensionElement($extensionElement)
|
||||
{
|
||||
$this->extensionElement = $extensionElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the entry of the feed.
|
||||
*
|
||||
* @return Entry
|
||||
*/
|
||||
public function getEntry()
|
||||
{
|
||||
return $this->entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the entry of the feed.
|
||||
*
|
||||
* @param Entry $entry The entry of the feed.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setEntry($entry)
|
||||
{
|
||||
$this->entry = $entry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the feed object.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
|
||||
$xmlWriter->startElementNS('atom', 'feed', Resources::ATOM_NAMESPACE);
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the feed object.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
|
||||
if (!is_null($this->attributes)) {
|
||||
if (is_array($this->attributes)) {
|
||||
foreach (
|
||||
$this->attributes
|
||||
as $attributeName => $attributeValue
|
||||
) {
|
||||
$xmlWriter->writeAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($this->author)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->author,
|
||||
Resources::AUTHOR
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->category)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->category,
|
||||
Resources::CATEGORY
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->contributor)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->contributor,
|
||||
Resources::CONTRIBUTOR
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->generator)) {
|
||||
$this->generator->writeXml($xmlWriter);
|
||||
}
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'icon',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->icon
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'logo',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->logo
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'id',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->id
|
||||
);
|
||||
|
||||
if (!is_null($this->link)) {
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->link,
|
||||
Resources::LINK
|
||||
);
|
||||
}
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'rights',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->rights
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'subtitle',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->subtitle
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'title',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->title
|
||||
);
|
||||
|
||||
if (!is_null($this->updated)) {
|
||||
$xmlWriter->writeElementNS(
|
||||
'atom',
|
||||
'updated',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->updated->format(\DateTime::ATOM)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
@@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Utilities;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
|
||||
/**
|
||||
* The generator class of ATOM library.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Generator extends AtomBase
|
||||
{
|
||||
/**
|
||||
* The of the generator.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
/**
|
||||
* The Uri of the generator.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uri;
|
||||
|
||||
/**
|
||||
* The version of the generator.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
/**
|
||||
* Creates a generator instance with specified XML string.
|
||||
*
|
||||
* @param string $xmlString A string representing a generator
|
||||
* instance.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public static function parseXml($xmlString)
|
||||
{
|
||||
$generatorXml = new \SimpleXMLElement($xmlString);
|
||||
$generatorArray = (array)$generatorXml;
|
||||
$attributes = $generatorXml->attributes();
|
||||
if (!empty($attributes['uri'])) {
|
||||
$this->uri = (string)$attributes['uri'];
|
||||
}
|
||||
|
||||
if (!empty($attributes['version'])) {
|
||||
$this->version = (string)$attributes['version'];
|
||||
}
|
||||
|
||||
$this->text = (string)$generatorXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an ATOM generator instance with specified name.
|
||||
*
|
||||
* @param string $text The text content of the generator.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function __construct($text = null)
|
||||
{
|
||||
if (!empty($text)) {
|
||||
$this->text = $text;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the text of the generator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of the generator.
|
||||
*
|
||||
* @param string $text The text of the generator.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URI of the generator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URI of the generator.
|
||||
*
|
||||
* @param string $uri The URI of the generator.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the version of the generator.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version of the generator.
|
||||
*
|
||||
* @param string $version The version of the generator.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setVersion($version)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the generator.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
Resources::CATEGORY,
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
|
||||
$this->writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
'uri',
|
||||
$this->uri
|
||||
);
|
||||
|
||||
$this->writeOptionalAttribute(
|
||||
$xmlWriter,
|
||||
'version',
|
||||
$this->version
|
||||
);
|
||||
|
||||
$xmlWriter->writeRaw($this->text);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Utilities;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
|
||||
/**
|
||||
* The person class of ATOM library.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Person extends AtomBase
|
||||
{
|
||||
/**
|
||||
* The name of the person.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The Uri of the person.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $uri;
|
||||
|
||||
/**
|
||||
* The email of the person.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $email;
|
||||
|
||||
/**
|
||||
* Creates an ATOM person instance with specified name.
|
||||
*
|
||||
* @param string $name The name of the person.
|
||||
*/
|
||||
public function __construct($name = Resources::EMPTY_STRING)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the properties with a specified XML string.
|
||||
*
|
||||
* @param string $xmlString An XML based string representing
|
||||
* the Person instance.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
$personXml = simplexml_load_string($xmlString);
|
||||
$attributes = $personXml->attributes();
|
||||
$personArray = (array)$personXml;
|
||||
|
||||
if (array_key_exists('name', $personArray)) {
|
||||
$this->name = (string)$personArray['name'];
|
||||
}
|
||||
|
||||
if (array_key_exists('uri', $personArray)) {
|
||||
$this->uri = (string)$personArray['uri'];
|
||||
}
|
||||
|
||||
if (array_key_exists('email', $personArray)) {
|
||||
$this->email = (string)$personArray['email'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the person.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name of the person.
|
||||
*
|
||||
* @param string $name The name of the person.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the URI of the person.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getUri()
|
||||
{
|
||||
return $this->uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URI of the person.
|
||||
*
|
||||
* @param string $uri The URI of the person.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUri($uri)
|
||||
{
|
||||
$this->uri = $uri;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the email of the person.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the email of the person.
|
||||
*
|
||||
* @param string $email The email of the person.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setEmail($email)
|
||||
{
|
||||
$this->email = $email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the person.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
'person',
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a inner XML representing the person.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->writeElementNS(
|
||||
'atom',
|
||||
'name',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->name
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'uri',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->uri
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'email',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->email
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,632 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* LICENSE: Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* PHP version 5
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
namespace WindowsAzure\Common\Internal\Atom;
|
||||
use WindowsAzure\Common\Internal\Validate;
|
||||
use WindowsAzure\Common\Internal\Resources;
|
||||
|
||||
/**
|
||||
* The source class of ATOM library.
|
||||
*
|
||||
* @category Microsoft
|
||||
* @package WindowsAzure\Common\Internal\Atom
|
||||
* @author Azure PHP SDK <azurephpsdk@microsoft.com>
|
||||
* @copyright 2012 Microsoft Corporation
|
||||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
|
||||
* @version Release: 0.4.1_2015-03
|
||||
* @link https://github.com/WindowsAzure/azure-sdk-for-php
|
||||
*/
|
||||
|
||||
class Source extends AtomBase
|
||||
{
|
||||
// @codingStandardsIgnoreStart
|
||||
|
||||
/**
|
||||
* The author the source.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $author;
|
||||
|
||||
/**
|
||||
* The category of the source.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $category;
|
||||
|
||||
/**
|
||||
* The contributor of the source.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $contributor;
|
||||
|
||||
/**
|
||||
* The generator of the source.
|
||||
*
|
||||
* @var Generator
|
||||
*/
|
||||
protected $generator;
|
||||
|
||||
/**
|
||||
* The icon of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $icon;
|
||||
|
||||
/**
|
||||
* The ID of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* The link of the source.
|
||||
*
|
||||
* @var AtomLink
|
||||
*/
|
||||
protected $link;
|
||||
|
||||
/**
|
||||
* The logo of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $logo;
|
||||
|
||||
/**
|
||||
* The rights of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $rights;
|
||||
|
||||
/**
|
||||
* The subtitle of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $subtitle;
|
||||
|
||||
/**
|
||||
* The title of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $title;
|
||||
|
||||
/**
|
||||
* The update of the source.
|
||||
*
|
||||
* @var \DateTime
|
||||
*/
|
||||
protected $updated;
|
||||
|
||||
/**
|
||||
* The extension element of the source.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $extensionElement;
|
||||
|
||||
/**
|
||||
* Creates an ATOM FEED object with default parameters.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->attributes = array();
|
||||
$this->category = array();
|
||||
$this->contributor = array();
|
||||
$this->author = array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a source object with specified XML string.
|
||||
*
|
||||
* @param string $xmlString The XML string representing a source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function parseXml($xmlString)
|
||||
{
|
||||
$sourceXml = new \SimpleXMLElement($xmlString);
|
||||
$attributes = $sourceXml->attributes();
|
||||
$sourceArray = (array)$sourceXml;
|
||||
|
||||
if (array_key_exists(Resources::AUTHOR, $sourceArray)) {
|
||||
$this->content = $this->processAuthorNode($sourceArray);
|
||||
}
|
||||
|
||||
if (array_key_exists(Resources::CATEGORY, $sourceArray)) {
|
||||
$this->category = $this->processCategoryNode($sourceArray);
|
||||
}
|
||||
|
||||
if (array_key_exists(Resources::CONTRIBUTOR, $sourceArray)) {
|
||||
$this->contributor = $this->processContributorNode($sourceArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('generator', $sourceArray)) {
|
||||
$generator = new Generator();
|
||||
$generator->setText((string)$sourceArray['generator']->asXML());
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
if (array_key_exists('icon', $sourceArray)) {
|
||||
$this->icon = (string)$sourceArray['icon'];
|
||||
}
|
||||
|
||||
if (array_key_exists('id', $sourceArray)) {
|
||||
$this->id = (string)$sourceArray['id'];
|
||||
}
|
||||
|
||||
if (array_key_exists(Resources::LINK, $sourceArray)) {
|
||||
$this->link = $this->processLinkNode($sourceArray);
|
||||
}
|
||||
|
||||
if (array_key_exists('logo', $sourceArray)) {
|
||||
$this->logo = (string)$sourceArray['logo'];
|
||||
}
|
||||
|
||||
if (array_key_exists('rights', $sourceArray)) {
|
||||
$this->rights = (string)$sourceArray['rights'];
|
||||
}
|
||||
|
||||
if (array_key_exists('subtitle', $sourceArray)) {
|
||||
$this->subtitle = (string)$sourceArray['subtitle'];
|
||||
}
|
||||
|
||||
if (array_key_exists('title', $sourceArray)) {
|
||||
$this->title = (string)$sourceArray['title'];
|
||||
}
|
||||
|
||||
if (array_key_exists('updated', $sourceArray)) {
|
||||
$this->updated = \DateTime::createFromFormat(
|
||||
\DateTime::ATOM,
|
||||
(string)$sourceArray['updated']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the author of the source.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getAuthor()
|
||||
{
|
||||
return $this->author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the author of the source.
|
||||
*
|
||||
* @param array $author An array of authors of the sources.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setAuthor($author)
|
||||
{
|
||||
$this->author = $author;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the category of the source.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category of the source.
|
||||
*
|
||||
* @param array $category The category of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setCategory($category)
|
||||
{
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets contributor.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getContributor()
|
||||
{
|
||||
return $this->contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contributor.
|
||||
*
|
||||
* @param array $contributor The contributors of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setContributor($contributor)
|
||||
{
|
||||
$this->contributor = $contributor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets generator.
|
||||
*
|
||||
* @return Generator
|
||||
*/
|
||||
public function getGenerator()
|
||||
{
|
||||
return $this->generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the generator.
|
||||
*
|
||||
* @param Generator $generator Sets the generator of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setGenerator($generator)
|
||||
{
|
||||
$this->generator = $generator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the icon of the source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIcon()
|
||||
{
|
||||
return $this->icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the icon of the source.
|
||||
*
|
||||
* @param string $icon The icon of the source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setIcon($icon)
|
||||
{
|
||||
$this->icon = $icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the ID of the source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ID of the source.
|
||||
*
|
||||
* @param string $id The ID of the source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the link of the source.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getLink()
|
||||
{
|
||||
return $this->link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the link of the source.
|
||||
*
|
||||
* @param array $link The link of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLink($link)
|
||||
{
|
||||
$this->link = $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the logo of the source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLogo()
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the logo of the source.
|
||||
*
|
||||
* @param string $logo The logo of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setLogo($logo)
|
||||
{
|
||||
$this->logo = $logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rights of the source.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getRights()
|
||||
{
|
||||
return $this->rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rights of the source.
|
||||
*
|
||||
* @param string $rights The rights of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setRights($rights)
|
||||
{
|
||||
$this->rights = $rights;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sub title.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSubtitle()
|
||||
{
|
||||
return $this->subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sub title of the source.
|
||||
*
|
||||
* @param string $subtitle Sets the sub title of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setSubtitle($subtitle)
|
||||
{
|
||||
$this->subtitle = $subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the title of the source.
|
||||
*
|
||||
* @return string.
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title of the source.
|
||||
*
|
||||
* @param string $title The title of the source.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the updated.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getUpdated()
|
||||
{
|
||||
return $this->updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the updated.
|
||||
*
|
||||
* @param \DateTime $updated updated
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setUpdated($updated)
|
||||
{
|
||||
$this->updated = $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the extension element.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getExtensionElement()
|
||||
{
|
||||
return $this->extensionElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the extension element.
|
||||
*
|
||||
* @param string $extensionElement The extension element.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function setExtensionElement($extensionElement)
|
||||
{
|
||||
$this->extensionElement = $extensionElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an XML representing the source object.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
$xmlWriter->startElementNS(
|
||||
'atom',
|
||||
'source',
|
||||
Resources::ATOM_NAMESPACE
|
||||
);
|
||||
$this->writeInnerXml($xmlWriter);
|
||||
$xmlWriter->endElement();
|
||||
}
|
||||
/**
|
||||
* Writes a inner XML representing the source object.
|
||||
*
|
||||
* @param \XMLWriter $xmlWriter The XML writer.
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
public function writeInnerXml($xmlWriter)
|
||||
{
|
||||
Validate::notNull($xmlWriter, 'xmlWriter');
|
||||
if (!is_null($this->attributes)) {
|
||||
if (is_array($this->attributes)) {
|
||||
foreach ($this->attributes as $attributeName => $attributeValue) {
|
||||
$xmlWriter->writeAttribute($attributeName, $attributeValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_null($this->author)) {
|
||||
Validate::isArray($this->author, Resources::AUTHOR);
|
||||
$this->writeArrayItem($xmlWriter, $this->author, Resources::AUTHOR);
|
||||
}
|
||||
|
||||
if (!is_null($this->category)) {
|
||||
Validate::isArray($this->category, Resources::CATEGORY);
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->category,
|
||||
Resources::CATEGORY
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->contributor)) {
|
||||
Validate::isArray($this->contributor, Resources::CONTRIBUTOR);
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->contributor,
|
||||
Resources::CONTRIBUTOR
|
||||
);
|
||||
}
|
||||
|
||||
if (!is_null($this->generator)) {
|
||||
$this->generator->writeXml($xmlWriter);
|
||||
}
|
||||
|
||||
if (!is_null($this->icon)) {
|
||||
$xmlWriter->writeElementNS(
|
||||
'atom',
|
||||
'icon',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->icon
|
||||
);
|
||||
}
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'logo',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->logo
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'id',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->id
|
||||
);
|
||||
|
||||
if (!is_null($this->link)) {
|
||||
Validate::isArray($this->link, Resources::LINK);
|
||||
$this->writeArrayItem(
|
||||
$xmlWriter,
|
||||
$this->link,
|
||||
Resources::LINK
|
||||
);
|
||||
}
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'rights',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->rights
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'subtitle',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->subtitle
|
||||
);
|
||||
|
||||
$this->writeOptionalElementNS(
|
||||
$xmlWriter,
|
||||
'atom',
|
||||
'title',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->title
|
||||
);
|
||||
|
||||
if (!is_null($this->updated)) {
|
||||
$xmlWriter->writeElementNS(
|
||||
'atom',
|
||||
'updated',
|
||||
Resources::ATOM_NAMESPACE,
|
||||
$this->updated->format(\DateTime::ATOM)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreEnd
|
||||
Reference in New Issue
Block a user