mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-15 18:23:26 +03:00
Added support for InputHandler::exists to check array of indexes.
- Updated documentation to reflect changes.
This commit is contained in:
@@ -293,14 +293,26 @@ class InputHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a input-item exist
|
||||
* Check if a input-item exist.
|
||||
* If an array is as $index parameter the method returns true if all elements exist.
|
||||
*
|
||||
* @param string $index
|
||||
* @param string|array $index
|
||||
* @param array ...$methods
|
||||
* @return bool
|
||||
*/
|
||||
public function exists(string $index, ...$methods): bool
|
||||
public function exists($index, ...$methods): bool
|
||||
{
|
||||
// Check array
|
||||
if(is_array($index) === true) {
|
||||
foreach($index as $key) {
|
||||
if($this->value($key, null, ...$methods) === null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->value($index, null, ...$methods) !== null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user