mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
Collection > the getByIndex() method > returns element with given index
This commit is contained in:
@@ -188,6 +188,21 @@ trait MainTrait
|
||||
return Arrays::getLastElement($this->elements);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns element with given index
|
||||
*
|
||||
* @param mixed $index Index / key of the element
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getByIndex($index)
|
||||
{
|
||||
if (isset($this->elements[$index])) {
|
||||
return $this->elements[$index];
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns representation of object as array
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user