Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Mvc / Router / Http / Method.php
blobde2628a0ca9b6ec2e6f6ecb0dacf7e8de9e9dc44
1 <?php
2 /**
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
8 */
10 namespace Zend\Mvc\Router\Http;
12 use Traversable;
13 use Zend\Mvc\Router\Exception;
14 use Zend\Stdlib\ArrayUtils;
15 use Zend\Stdlib\RequestInterface as Request;
17 /**
18 * Method route.
20 class Method implements RouteInterface
22 /**
23 * Verb to match.
25 * @var string
27 protected $verb;
29 /**
30 * Default values.
32 * @var array
34 protected $defaults;
36 /**
37 * Create a new method route.
39 * @param string $verb
40 * @param array $defaults
42 public function __construct($verb, array $defaults = array())
44 $this->verb = $verb;
45 $this->defaults = $defaults;
48 /**
49 * factory(): defined by RouteInterface interface.
51 * @see \Zend\Mvc\Router\RouteInterface::factory()
52 * @param array|Traversable $options
53 * @return Method
54 * @throws Exception\InvalidArgumentException
56 public static function factory($options = array())
58 if ($options instanceof Traversable) {
59 $options = ArrayUtils::iteratorToArray($options);
60 } elseif (!is_array($options)) {
61 throw new Exception\InvalidArgumentException(__METHOD__ . ' expects an array or Traversable set of options');
64 if (!isset($options['verb'])) {
65 throw new Exception\InvalidArgumentException('Missing "verb" in options array');
68 if (!isset($options['defaults'])) {
69 $options['defaults'] = array();
72 return new static($options['verb'], $options['defaults']);
75 /**
76 * match(): defined by RouteInterface interface.
78 * @see \Zend\Mvc\Router\RouteInterface::match()
79 * @param Request $request
80 * @return RouteMatch|null
82 public function match(Request $request)
84 if (!method_exists($request, 'getMethod')) {
85 return null;
88 $requestVerb = strtoupper($request->getMethod());
89 $matchVerbs = explode(',', strtoupper($this->verb));
90 $matchVerbs = array_map('trim', $matchVerbs);
92 if (in_array($requestVerb, $matchVerbs)) {
93 return new RouteMatch($this->defaults);
96 return null;
99 /**
100 * assemble(): Defined by RouteInterface interface.
102 * @see \Zend\Mvc\Router\RouteInterface::assemble()
103 * @param array $params
104 * @param array $options
105 * @return mixed
107 public function assemble(array $params = array(), array $options = array())
109 // The request method does not contribute to the path, thus nothing is returned.
110 return '';
114 * getAssembledParams(): defined by RouteInterface interface.
116 * @see RouteInterface::getAssembledParams
117 * @return array
119 public function getAssembledParams()
121 return array();