From b930066168303fa8befd53f91c8861300f4b06ab Mon Sep 17 00:00:00 2001 From: Larry Garfield Date: Thu, 22 Nov 2012 23:22:12 -0600 Subject: [PATCH] Add Route::hasOption() and Route::hasRequirement() methods. --- src/Symfony/Component/Routing/Route.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Symfony/Component/Routing/Route.php b/src/Symfony/Component/Routing/Route.php index abc37aa773ae..38fc3f494a95 100644 --- a/src/Symfony/Component/Routing/Route.php +++ b/src/Symfony/Component/Routing/Route.php @@ -233,6 +233,18 @@ public function getOption($name) return isset($this->options[$name]) ? $this->options[$name] : null; } + /** + * Checks if a an option has been set + * + * @param string $name An option name + * + * @return Boolean true if the option is set, false otherwise + */ + public function hasOption($name) + { + return array_key_exists($name, $this->options); + } + /** * Returns the defaults. * @@ -377,6 +389,18 @@ public function getRequirement($key) return isset($this->requirements[$key]) ? $this->requirements[$key] : null; } + /** + * Checks if a requirement is set for the given key. + * + * @param string $name A variable name + * + * @return Boolean true if a requirement is specified, false otherwise + */ + public function hasRequirement($key) + { + return array_key_exists($key, $this->requirements); + } + /** * Sets a requirement for the given key. *