Added support for InputHandler::exists to check array of indexes.

- Updated documentation to reflect changes.
This commit is contained in:
Simon Sessingø
2021-05-20 15:03:56 +02:00
parent 03ef9dfb74
commit ece9d30905
2 changed files with 37 additions and 3 deletions

View File

@@ -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;
}