Created
December 18, 2013 10:41
-
-
Save hagbarddenstore/8020327 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected function getParameterAs($key, $type, $default = null, $validation = ValidationType::None, $validationData = null) | |
| { | |
| if (!isset($this->passedArgs[$key])) | |
| { | |
| return $default; | |
| } | |
| // NOTE: Not sure if this is needed, my PHP-fu is weak. | |
| $value = null; | |
| switch ($type) | |
| { | |
| case 'string': | |
| $value = strval($this->passedArgs[$key]); | |
| break; | |
| case 'int': | |
| $value = intval($this->passedArgs[$key]); | |
| break; | |
| default: | |
| // TODO: Throw exception or do something else that's useful... | |
| return $default; | |
| break; | |
| } | |
| if ($this->validateParameter($value, $validation, $validationData)) | |
| { | |
| return $value; | |
| } | |
| return $default; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment