use zend router
[GitHub/Stricted/Domain-Control-Panel.git] / vendor / Zend / Mvc / Router / Http / RouteMatch.php
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
4 *
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
9
10 namespace Zend\Mvc\Router\Http;
11
12 use Zend\Mvc\Router\RouteMatch as BaseRouteMatch;
13
14 /**
15 * Part route match.
16 */
17 class RouteMatch extends BaseRouteMatch
18 {
19 /**
20 * Length of the matched path.
21 *
22 * @var int
23 */
24 protected $length;
25
26 /**
27 * Create a part RouteMatch with given parameters and length.
28 *
29 * @param array $params
30 * @param int $length
31 */
32 public function __construct(array $params, $length = 0)
33 {
34 parent::__construct($params);
35
36 $this->length = $length;
37 }
38
39 /**
40 * setMatchedRouteName(): defined by BaseRouteMatch.
41 *
42 * @see BaseRouteMatch::setMatchedRouteName()
43 * @param string $name
44 * @return RouteMatch
45 */
46 public function setMatchedRouteName($name)
47 {
48 if ($this->matchedRouteName === null) {
49 $this->matchedRouteName = $name;
50 } else {
51 $this->matchedRouteName = $name . '/' . $this->matchedRouteName;
52 }
53
54 return $this;
55 }
56
57 /**
58 * Merge parameters from another match.
59 *
60 * @param RouteMatch $match
61 * @return RouteMatch
62 */
63 public function merge(RouteMatch $match)
64 {
65 $this->params = array_merge($this->params, $match->getParams());
66 $this->length += $match->getLength();
67
68 $this->matchedRouteName = $match->getMatchedRouteName();
69
70 return $this;
71 }
72
73 /**
74 * Get the matched path length.
75 *
76 * @return int
77 */
78 public function getLength()
79 {
80 return $this->length;
81 }
82 }