-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from alexdebril/issue/72
Issue/72
- Loading branch information
Showing
15 changed files
with
504 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php | ||
/* | ||
* This file is part of the feed-io package. | ||
* | ||
* (c) Alexandre Debril <alex.debril@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FeedIo\Feed\Item; | ||
|
||
class Author implements AuthorInterface | ||
{ | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected $uri; | ||
|
||
/** | ||
* @var int | ||
*/ | ||
protected $email; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName() | ||
{ | ||
return $this->name; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function setName($name) | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUri() | ||
{ | ||
return $this->uri; | ||
} | ||
|
||
/** | ||
* @param string $uri | ||
* @return $this | ||
*/ | ||
public function setUri($uri) | ||
{ | ||
$this->uri = $uri; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEmail() | ||
{ | ||
return $this->email; | ||
} | ||
|
||
/** | ||
* @param string $email | ||
* @return $this | ||
*/ | ||
public function setEmail($email) | ||
{ | ||
$this->email = $email; | ||
|
||
return $this; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/* | ||
* This file is part of the feed-io package. | ||
* | ||
* (c) Alexandre Debril <alex.debril@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FeedIo\Feed\Item; | ||
|
||
/** | ||
* Describe a Author instance | ||
* | ||
*/ | ||
interface AuthorInterface | ||
{ | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getName(); | ||
|
||
/** | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function setName($name); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getUri(); | ||
|
||
/** | ||
* @param string $uri | ||
* @return $this | ||
*/ | ||
public function setUri($uri); | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEmail(); | ||
|
||
/** | ||
* @param string $email | ||
* @return $this | ||
*/ | ||
public function setEmail($email); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/* | ||
* This file is part of the feed-io package. | ||
* | ||
* (c) Alexandre Debril <alex.debril@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FeedIo\Rule\Atom; | ||
|
||
use FeedIo\Feed\Item\AuthorInterface; | ||
use FeedIo\Feed\ItemInterface; | ||
use FeedIo\Feed\NodeInterface; | ||
use FeedIo\RuleAbstract; | ||
|
||
class Author extends RuleAbstract | ||
{ | ||
|
||
const NODE_NAME = 'author'; | ||
|
||
/** | ||
* @param NodeInterface $node | ||
* @param \DOMElement $element | ||
* @return mixed | ||
*/ | ||
public function setProperty(NodeInterface $node, \DOMElement $element) | ||
{ | ||
if ($node instanceof ItemInterface) { | ||
$author = $node->newAuthor(); | ||
$author->setName($this->getAttributeValue($element, 'name')); | ||
$author->setUri($this->getAttributeValue($element, 'uri')); | ||
$author->setEmail($this->getAttributeValue($element, 'email')); | ||
$node->setAuthor($author); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* creates the accurate DomElement content according to the $item's property | ||
* | ||
* @param \DomDocument $document | ||
* @param NodeInterface $node | ||
* @return \DomElement | ||
*/ | ||
public function createElement(\DomDocument $document, NodeInterface $node) | ||
{ | ||
if ($node instanceof ItemInterface && !is_null($node->getAuthor())) { | ||
$element = $document->createElement(static::NODE_NAME); | ||
$element->setAttribute('name', $node->getAuthor()->getName()); | ||
$element->setAttribute('uri', $node->getAuthor()->getUri()); | ||
$element->setAttribute('email', $node->getAuthor()->getEmail()); | ||
|
||
return $element; | ||
} | ||
|
||
return; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/* | ||
* This file is part of the feed-io package. | ||
* | ||
* (c) Alexandre Debril <alex.debril@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FeedIo\Rule; | ||
|
||
use FeedIo\Feed\Item\AuthorInterface; | ||
use FeedIo\Feed\ItemInterface; | ||
use FeedIo\Feed\NodeInterface; | ||
use FeedIo\RuleAbstract; | ||
|
||
class Author extends RuleAbstract | ||
{ | ||
|
||
const NODE_NAME = 'author'; | ||
|
||
/** | ||
* @param NodeInterface $node | ||
* @param \DOMElement $element | ||
* @return mixed | ||
*/ | ||
public function setProperty(NodeInterface $node, \DOMElement $element) | ||
{ | ||
if ($node instanceof ItemInterface) { | ||
$author = $node->newAuthor(); | ||
$author->setName($element->nodeValue); | ||
$node->setAuthor($author); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* creates the accurate DomElement content according to the $item's property | ||
* | ||
* @param \DomDocument $document | ||
* @param NodeInterface $node | ||
* @return \DomElement|null | ||
*/ | ||
public function createElement(\DomDocument $document, NodeInterface $node) | ||
{ | ||
if ($node instanceof ItemInterface && !is_null($node->getAuthor())) { | ||
return $document->createElement($this->getNodeName(), $node->getAuthor()->getName()); | ||
} | ||
|
||
return; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.