3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
10 namespace Zend\Navigation\Page
;
12 use Zend\Navigation\Exception
;
15 * Represents a page that is defined by specifying a URI
17 class Uri
extends AbstractPage
24 protected $uri = null;
29 * @param string $uri page URI, must a string or null
31 * @return Uri fluent interface, returns self
32 * @throws Exception\InvalidArgumentException if $uri is invalid
34 public function setUri($uri)
36 if (null !== $uri && !is_string($uri)) {
37 throw new Exception\
InvalidArgumentException(
38 'Invalid argument: $uri must be a string or null'
51 public function getUri()
57 * Returns href for this page
59 * Includes the fragment identifier if it is set.
63 public function getHref()
65 $uri = $this->getUri();
67 $fragment = $this->getFragment();
68 if (null !== $fragment) {
69 if ('#' == substr($uri, -1)) {
70 return $uri . $fragment;
72 return $uri . '#' . $fragment;
80 * Returns an array representation of the page
84 public function toArray()
89 'uri' => $this->getUri(),