Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
Merge branch 'tag-renamed-interfaces' of https://github.com/prolic/zf2
Browse files Browse the repository at this point in the history
…into feature/zen27-tag
  • Loading branch information
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 77 deletions.
26 changes: 13 additions & 13 deletions src/Cloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@
class Cloud
{
/**
* Decorator for the cloud
* DecoratorInterface for the cloud
*
* @var \Zend\Tag\Cloud\Decorator\Cloud
* @var Cloud
*/
protected $_cloudDecorator = null;

/**
* Decorator for the tags
* DecoratorInterface for the tags
*
* @var \Zend\Tag\Cloud\Decorator\Tag
* @var Tag
*/
protected $_tagDecorator = null;

Expand Down Expand Up @@ -146,12 +146,12 @@ public function setTags(array $tags)
$itemList = $this->getItemList();

foreach ($tags as $tag) {
if ($tag instanceof Taggable) {
if ($tag instanceof TaggableInterface) {
$itemList[] = $tag;
} else if (is_array($tag)) {
$itemList[] = new Item($tag);
} else {
throw new InvalidArgumentException('Tag must be an instance of Zend\Tag\Taggable or an array');
throw new InvalidArgumentException('Tag must be an instance of Zend\Tag\TaggableInterface or an array');
}
}

Expand All @@ -161,19 +161,19 @@ public function setTags(array $tags)
/**
* Append a single tag to the cloud
*
* @param \Zend\Tag\Taggable|array $tag
* @param \Zend\Tag\TaggableInterface|array $tag
* @throws \Zend\Tag\Exception\InvalidArgumentException
* @return \Zend\Tag\Cloud
*/
public function appendTag($tag)
{
$tags = $this->getItemList();
if ($tag instanceof Taggable) {
if ($tag instanceof TaggableInterface) {
$tags[] = $tag;
} else if (is_array($tag)) {
$tags[] = new Item($tag);
} else {
throw new InvalidArgumentException('Tag must be an instance of Zend\Tag\Taggable or an array');
throw new InvalidArgumentException('Tag must be an instance of Zend\Tag\TaggableInterface or an array');
}

return $this;
Expand Down Expand Up @@ -232,7 +232,7 @@ public function setCloudDecorator($decorator)
}

if (!($decorator instanceof Cloud\Decorator\Cloud)) {
throw new InvalidArgumentException('Decorator is no instance of Zend\Tag\Cloud\Decorator\Cloud');
throw new InvalidArgumentException('DecoratorInterface is no instance of Zend\Tag\Cloud\Decorator\Cloud');
}

$this->_cloudDecorator = $decorator;
Expand All @@ -243,7 +243,7 @@ public function setCloudDecorator($decorator)
/**
* Get the decorator for the cloud
*
* @return \Zend\Tag\Cloud\Decorator\Cloud
* @return Cloud
*/
public function getCloudDecorator()
{
Expand Down Expand Up @@ -279,7 +279,7 @@ public function setTagDecorator($decorator)
}

if (!($decorator instanceof Cloud\Decorator\Tag)) {
throw new InvalidArgumentException('Decorator is no instance of Zend\Tag\Cloud\Decorator\Tag');
throw new InvalidArgumentException('DecoratorInterface is no instance of Zend\Tag\Cloud\Decorator\Tag');
}

$this->_tagDecorator = $decorator;
Expand All @@ -290,7 +290,7 @@ public function setTagDecorator($decorator)
/**
* Get the decorator for the tags
*
* @return \Zend\Tag\Cloud\Decorator\Tag
* @return Tag
*/
public function getTagDecorator()
{
Expand Down
2 changes: 1 addition & 1 deletion src/Cloud/Decorator/Cloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace Zend\Tag\Cloud\Decorator;

use Zend\Tag\Cloud\Decorator;
use Zend\Tag\Cloud\Decorator\DecoratorInterface as Decorator;

/**
* Abstract class for cloud decorators
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Tag\Cloud;
namespace Zend\Tag\Cloud\Decorator;

/**
* Interface for decorators
Expand All @@ -30,7 +30,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Decorator
interface DecoratorInterface
{
/**
* Constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Tag\Cloud\Decorator;
namespace Zend\Tag\Cloud\Decorator\Exception;

/**
* Exception class for Zend_Tag_Cloud_Decorator
Expand All @@ -29,6 +29,6 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception extends \Zend\Tag\Exception
interface ExceptionInterface extends \Zend\Tag\Exception\ExceptionInterface
{
}
2 changes: 1 addition & 1 deletion src/Cloud/Decorator/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class InvalidArgumentException
extends \InvalidArgumentException
implements \Zend\Tag\Cloud\Decorator\Exception
implements ExceptionInterface
{}
11 changes: 5 additions & 6 deletions src/Cloud/Decorator/HtmlCloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@
/**
* Simple HTML decorator for clouds
*
* @uses \Zend\Tag\Cloud\Decorator\Cloud
* @category Zend
* @package Zend_Tag
* @uses \Zend\Tag\Cloud\Decorator\Cloud
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down Expand Up @@ -68,7 +66,7 @@ public function getEncoding()
* Set encoding
*
* @param string
* @return \Zend\Tag\Cloud\Decorator\HTMLCloud
* @return HTMLCloud
*/
public function setEncoding($value)
{
Expand All @@ -80,7 +78,7 @@ public function setEncoding($value)
* Set the HTML tags surrounding all tags
*
* @param array $htmlTags
* @return \Zend\Tag\Cloud\Decorator\HTMLCloud
* @return HTMLCloud
*/
public function setHTMLTags(array $htmlTags)
{
Expand All @@ -102,7 +100,7 @@ public function getHTMLTags()
* Set the separator between the single tags
*
* @param string
* @return \Zend\Tag\Cloud\Decorator\HTMLCloud
* @return HTMLCloud
*/
public function setSeparator($separator)
{
Expand All @@ -124,12 +122,13 @@ public function getSeparator()
* Defined by Zend\Tag\Cloud\Decorator\Cloud
*
* @param array $tags
* @throws InvalidArgumentException
* @return string
*/
public function render($tags)
{
if (!is_array($tags)) {
throw new Exception(sprintf(
throw new InvalidArgumentException(sprintf(
'HtmlCloud::render() expects an array argument; received "%s"',
(is_object($tags) ? get_class($tags) : gettype($tags))
));
Expand Down
32 changes: 15 additions & 17 deletions src/Cloud/Decorator/HtmlTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@
/**
* Simple HTML decorator for tags
*
* @uses \Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException
* @uses \Zend\Tag\Cloud\Decorator\Tag
* @category Zend
* @package Zend_Tag
* @uses \Zend\Tag\Cloud\Decorator\Tag
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
Expand Down Expand Up @@ -91,9 +88,9 @@ class HtmlTag extends Tag
* Set a list of classes to use instead of fontsizes
*
* @param array $classList
* @throws \Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException When the classlist is empty
* @throws \Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException When the classlist contains an invalid classname
* @return \Zend\Tag\Cloud\Decorator\HTMLTag
* @throws InvalidArgumentException When the classlist is empty
* @throws InvalidArgumentException When the classlist contains an invalid classname
* @return HTMLTag
*/
public function setClassList(array $classList = null)
{
Expand Down Expand Up @@ -137,7 +134,7 @@ public function getEncoding()
* Set encoding
*
* @param string $value
* @return \Zend\Tag\Cloud\Decorator\HTMLTag
* @return HTMLTag
*/
public function setEncoding($value)
{
Expand All @@ -151,8 +148,8 @@ public function setEncoding($value)
* Possible values are: em, ex, px, in, cm, mm, pt, pc and %
*
* @param string $fontSizeUnit
* @throws \Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException When an invalid fontsize unit is specified
* @return \Zend\Tag\Cloud\Decorator\HTMLTag
* @throws InvalidArgumentException When an invalid fontsize unit is specified
* @return HTMLTag
*/
public function setFontSizeUnit($fontSizeUnit)
{
Expand All @@ -178,7 +175,7 @@ public function getFontSizeUnit()
* Set the HTML tags surrounding the <a> element
*
* @param array $htmlTags
* @return \Zend\Tag\Cloud\Decorator\HTMLTag
* @return HTMLTag
*/
public function setHTMLTags(array $htmlTags)
{
Expand All @@ -200,8 +197,8 @@ public function getHTMLTags()
* Set maximum font size
*
* @param integer $maxFontSize
* @throws \Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException When fontsize is not numeric
* @return \Zend\Tag\Cloud\Decorator\HTMLTag
* @throws InvalidArgumentException When fontsize is not numeric
* @return HTMLTag
*/
public function setMaxFontSize($maxFontSize)
{
Expand All @@ -228,8 +225,8 @@ public function getMaxFontSize()
* Set minimum font size
*
* @param int $minFontSize
* @throws \Zend\Tag\Cloud\Decorator\Exception\InvalidArgumentException When fontsize is not numeric
* @return \Zend\Tag\Cloud\Decorator\HTMLTag
* @throws InvalidArgumentException When fontsize is not numeric
* @return HTMLTag
*/
public function setMinFontSize($minFontSize)
{
Expand All @@ -253,15 +250,16 @@ public function getMinFontSize()
}

/**
* Defined by Zend\Tag\Cloud\Decorator\Tag
* Defined by Tag
*
* @param \Zend\Tag\ItemList $tags
* @param ItemList $tags
* @throws InvalidArgumentException
* @return array
*/
public function render($tags)
{
if (!$tags instanceof ItemList) {
throw new Exception(sprintf(
throw new InvalidArgumentException(sprintf(
'HtmlTag::render() expects a Zend\Tag\ItemList argument; received "%s"',
(is_object($tags) ? get_class($tags) : gettype($tags))
));
Expand Down
2 changes: 1 addition & 1 deletion src/Cloud/Decorator/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

namespace Zend\Tag\Cloud\Decorator;

use Zend\Tag\Cloud\Decorator;
use Zend\Tag\Cloud\Decorator\DecoratorInterface as Decorator;

/**
* Abstract class for tag decorators
Expand Down
8 changes: 5 additions & 3 deletions src/Cloud/DecoratorBroker.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@

namespace Zend\Tag\Cloud;

use Zend\Loader\PluginBroker;
use Zend\Loader\PluginBroker,
Zend\Tag\Exception\InvalidArgumentException,
Zend\Tag\Cloud\Decorator\DecoratorInterface as Decorator;

/**
* Broker for decorator instances
Expand All @@ -44,12 +46,12 @@ class DecoratorBroker extends PluginBroker
*
* @param mixed $plugin
* @return true
* @throws Exception
* @throws InvalidArgumentException
*/
protected function validatePlugin($plugin)
{
if (!$plugin instanceof Decorator) {
throw new Exception('Tag cloud decorators must implement Zend\Tag\Cloud\Decorator');
throw new InvalidArgumentException('Tag cloud decorators must implement Zend\Tag\Cloud\Decorator\DecoratorInterface');
}
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Tag;
namespace Zend\Tag\Exception;

/**
* Exception interface for Zend\Tag
Expand All @@ -28,6 +28,6 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
interface ExceptionInterface
{
}
2 changes: 1 addition & 1 deletion src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class InvalidArgumentException
extends \InvalidArgumentException
implements \Zend\Tag\Exception
implements \Zend\Tag\Exception\ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Exception/OutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

class OutOfBoundsException
extends \OutOfBoundsException
implements \Zend\Tag\Exception
implements \Zend\Tag\Exception\ExceptionInterface
{}
Loading

0 comments on commit a0b34c2

Please sign in to comment.