diff --git a/src/Cloud.php b/src/Cloud.php index 323d5df..8c3c777 100644 --- a/src/Cloud.php +++ b/src/Cloud.php @@ -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; @@ -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'); } } @@ -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; @@ -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; @@ -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() { @@ -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; @@ -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() { diff --git a/src/Cloud/Decorator/Cloud.php b/src/Cloud/Decorator/Cloud.php index 9ab2063..926b033 100644 --- a/src/Cloud/Decorator/Cloud.php +++ b/src/Cloud/Decorator/Cloud.php @@ -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 diff --git a/src/Cloud/Decorator.php b/src/Cloud/Decorator/DecoratorInterface.php similarity index 95% rename from src/Cloud/Decorator.php rename to src/Cloud/Decorator/DecoratorInterface.php index 711eaf7..0359e77 100644 --- a/src/Cloud/Decorator.php +++ b/src/Cloud/Decorator/DecoratorInterface.php @@ -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 @@ -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 diff --git a/src/Cloud/Decorator/Exception.php b/src/Cloud/Decorator/Exception/ExceptionInterface.php similarity index 88% rename from src/Cloud/Decorator/Exception.php rename to src/Cloud/Decorator/Exception/ExceptionInterface.php index cfbbd90..e9490df 100644 --- a/src/Cloud/Decorator/Exception.php +++ b/src/Cloud/Decorator/Exception/ExceptionInterface.php @@ -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 @@ -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 { } diff --git a/src/Cloud/Decorator/Exception/InvalidArgumentException.php b/src/Cloud/Decorator/Exception/InvalidArgumentException.php index 8a70e90..a51e981 100644 --- a/src/Cloud/Decorator/Exception/InvalidArgumentException.php +++ b/src/Cloud/Decorator/Exception/InvalidArgumentException.php @@ -3,5 +3,5 @@ class InvalidArgumentException extends \InvalidArgumentException - implements \Zend\Tag\Cloud\Decorator\Exception + implements ExceptionInterface {} \ No newline at end of file diff --git a/src/Cloud/Decorator/HtmlCloud.php b/src/Cloud/Decorator/HtmlCloud.php index 662adf8..b57100c 100644 --- a/src/Cloud/Decorator/HtmlCloud.php +++ b/src/Cloud/Decorator/HtmlCloud.php @@ -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 */ @@ -68,7 +66,7 @@ public function getEncoding() * Set encoding * * @param string - * @return \Zend\Tag\Cloud\Decorator\HTMLCloud + * @return HTMLCloud */ public function setEncoding($value) { @@ -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) { @@ -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) { @@ -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)) )); diff --git a/src/Cloud/Decorator/HtmlTag.php b/src/Cloud/Decorator/HtmlTag.php index 7339cd9..141e899 100644 --- a/src/Cloud/Decorator/HtmlTag.php +++ b/src/Cloud/Decorator/HtmlTag.php @@ -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 */ @@ -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) { @@ -137,7 +134,7 @@ public function getEncoding() * Set encoding * * @param string $value - * @return \Zend\Tag\Cloud\Decorator\HTMLTag + * @return HTMLTag */ public function setEncoding($value) { @@ -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) { @@ -178,7 +175,7 @@ public function getFontSizeUnit() * Set the HTML tags surrounding the element * * @param array $htmlTags - * @return \Zend\Tag\Cloud\Decorator\HTMLTag + * @return HTMLTag */ public function setHTMLTags(array $htmlTags) { @@ -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) { @@ -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) { @@ -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)) )); diff --git a/src/Cloud/Decorator/Tag.php b/src/Cloud/Decorator/Tag.php index 9740739..b97d4b3 100644 --- a/src/Cloud/Decorator/Tag.php +++ b/src/Cloud/Decorator/Tag.php @@ -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 diff --git a/src/Cloud/DecoratorBroker.php b/src/Cloud/DecoratorBroker.php index 58d65b6..9192a4c 100644 --- a/src/Cloud/DecoratorBroker.php +++ b/src/Cloud/DecoratorBroker.php @@ -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 @@ -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; } diff --git a/src/Exception.php b/src/Exception/ExceptionInterface.php similarity index 94% rename from src/Exception.php rename to src/Exception/ExceptionInterface.php index ebaea17..1dc92e7 100644 --- a/src/Exception.php +++ b/src/Exception/ExceptionInterface.php @@ -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 @@ -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 { } diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 67c9f44..871d682 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -3,5 +3,5 @@ class InvalidArgumentException extends \InvalidArgumentException - implements \Zend\Tag\Exception + implements \Zend\Tag\Exception\ExceptionInterface {} \ No newline at end of file diff --git a/src/Exception/OutOfBoundsException.php b/src/Exception/OutOfBoundsException.php index 1720770..16e4080 100644 --- a/src/Exception/OutOfBoundsException.php +++ b/src/Exception/OutOfBoundsException.php @@ -3,5 +3,5 @@ class OutOfBoundsException extends \OutOfBoundsException - implements \Zend\Tag\Exception + implements \Zend\Tag\Exception\ExceptionInterface {} \ No newline at end of file diff --git a/src/Item.php b/src/Item.php index 851d21b..799f612 100644 --- a/src/Item.php +++ b/src/Item.php @@ -22,14 +22,12 @@ namespace Zend\Tag; /** - * @uses \Zend\Tag\Exception\InvalidArgumentException - * @uses \Zend\Tag\Taggable * @category Zend * @package Zend_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 */ -class Item implements Taggable +class Item implements TaggableInterface { /** * Title of the tag @@ -115,7 +113,7 @@ public function setOptions(array $options) } /** - * Defined by Zend\Tag\Taggable + * Defined by Zend\Tag\TaggableInterface * * @return string */ @@ -142,7 +140,7 @@ public function setTitle($title) } /** - * Defined by Zend\Tag\Taggable + * Defined by Zend\Tag\TaggableInterface * * @return float */ @@ -184,7 +182,7 @@ public function setParams(array $params) } /** - * Defined by Zend\Tag\Taggable + * Defined by Zend\Tag\TaggableInterface * * @param string $name * @param mixed $value @@ -197,7 +195,7 @@ public function setParam($name, $value) } /** - * Defined by Zend\Tag\Taggable + * Defined by Zend\Tag\TaggableInterface * * @param string $name * @return mixed diff --git a/src/ItemList.php b/src/ItemList.php index 401b132..37d93da 100644 --- a/src/ItemList.php +++ b/src/ItemList.php @@ -24,20 +24,18 @@ use Zend\Amf\Parser\Exception; use Zend\Tag\Exception\InvalidArgumentException, - Zend\Tag\Exception\OutOfBoundsException; + Zend\Tag\Exception\OutOfBoundsException, + Countable, + SeekableIterator, + ArrayAccess; /** - * @uses ArrayAccess - * @uses Countable - * @uses SeekableIterator - * @uses \Zend\Tag\Exception\InvalidArgumentException - * @uses \Zend\Tag\Exception\OutOfBoundsException * @category Zend * @package Zend_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 */ -class ItemList implements \Countable, \SeekableIterator, \ArrayAccess +class ItemList implements Countable, SeekableIterator, ArrayAccess { /** * Items in this list @@ -60,7 +58,7 @@ public function count() * Spread values in the items relative to their weight * * @param array $values - * @throws \Zend\Tag\Exception\InvalidArgumentException When value list is empty + * @throws InvalidArgumentException When value list is empty * @return void */ public function spreadWeightValues(array $values) @@ -120,7 +118,7 @@ public function spreadWeightValues(array $values) * Seek to an absolute positio * * @param integer $index - * @throws \Zend\Tag\Exception\OutOfBoundsException When the seek position is invalid + * @throws OutOfBoundsException When the seek position is invalid * @return void */ public function seek($index) @@ -202,7 +200,7 @@ public function offsetExists($offset) { * Get the value of an offset * * @param mixed $offset - * @return \Zend\Tag\Taggable + * @return TaggableInterface */ public function offsetGet($offset) { return $this->_items[$offset]; @@ -212,15 +210,15 @@ public function offsetGet($offset) { * Append a new item * * @param mixed $offset - * @param \Zend\Tag\Taggable $item - * @throws \Zend\Tag\Exception\OutOfBoundsException When item does not implement Zend\Tag\Taggable + * @param TaggableInterface $item + * @throws OutOfBoundsException When item does not implement Zend\Tag\TaggableInterface * @return void */ public function offsetSet($offset, $item) { // We need to make that check here, as the method signature must be // compatible with ArrayAccess::offsetSet() - if (!($item instanceof Taggable)) { - throw new OutOfBoundsException('Item must implement Zend\Tag\Taggable'); + if (!($item instanceof TaggableInterface)) { + throw new OutOfBoundsException('Item must implement Zend\Tag\TaggableInterface'); } if ($offset === null) { diff --git a/src/Taggable.php b/src/TaggableInterface.php similarity index 98% rename from src/Taggable.php rename to src/TaggableInterface.php index 5a85c3a..feb2943 100644 --- a/src/Taggable.php +++ b/src/TaggableInterface.php @@ -27,7 +27,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 Taggable +interface TaggableInterface { /** * Get the title of the tag diff --git a/test/Cloud/CloudTest.php b/test/Cloud/CloudTest.php index 17ecbb9..f0b4348 100644 --- a/test/Cloud/CloudTest.php +++ b/test/Cloud/CloudTest.php @@ -76,7 +76,7 @@ public function testSetInvalidCloudDecorator() $cloud->setCloudDecorator(new \stdClass()); $this->fail('An expected Zend\Tag\Exception\InvalidArgumentException was not raised'); } catch (InvalidArgumentException $e) { - $this->assertEquals('Decorator is no instance of Zend\Tag\Cloud\Decorator\Cloud', $e->getMessage()); + $this->assertEquals('DecoratorInterface is no instance of Zend\Tag\Cloud\Decorator\Cloud', $e->getMessage()); } } @@ -106,7 +106,7 @@ public function testSetInvalidTagDecorator() $cloud->setTagDecorator(new \stdClass()); $this->fail('An expected Zend\Tag\Exception\InvalidArgumentException was not raised'); } catch (InvalidArgumentException $e) { - $this->assertEquals('Decorator is no instance of Zend\Tag\Cloud\Decorator\Tag', $e->getMessage()); + $this->assertEquals('DecoratorInterface is no instance of Zend\Tag\Cloud\Decorator\Tag', $e->getMessage()); } } @@ -153,7 +153,7 @@ public function testAppendInvalidTag() $cloud->appendTag('foo'); $this->fail('An expected Zend\Tag\Exception\InvalidArgumentException was not raised'); } catch (InvalidArgumentException $e) { - $this->assertEquals('Tag must be an instance of Zend\Tag\Taggable or an array', $e->getMessage()); + $this->assertEquals('Tag must be an instance of Zend\Tag\TaggableInterface or an array', $e->getMessage()); } } @@ -201,7 +201,7 @@ public function testSetInvalidTags() $cloud->setTags(array('foo')); $this->fail('An expected Zend\Tag\Exception\InvalidArgumentException was not raised'); } catch (InvalidArgumentException $e) { - $this->assertEquals('Tag must be an instance of Zend\Tag\Taggable or an array', $e->getMessage()); + $this->assertEquals('Tag must be an instance of Zend\Tag\TaggableInterface or an array', $e->getMessage()); } } diff --git a/test/ItemListTest.php b/test/ItemListTest.php index 14cc822..db6dd96 100644 --- a/test/ItemListTest.php +++ b/test/ItemListTest.php @@ -88,7 +88,7 @@ public function testInvalidItem() { $list = new Tag\ItemList(); - $this->setExpectedException('\Zend\Tag\Exception\OutOfBoundsException', 'Item must implement Zend\Tag\Taggable'); + $this->setExpectedException('\Zend\Tag\Exception\OutOfBoundsException', 'Item must implement Zend\Tag\TaggableInterface'); $list[] = 'test'; }