Skip to content

Commit

Permalink
Add ArrayType::first
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosmologist committed Nov 9, 2018
1 parent 4ca5cbe commit 36087e5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Gears/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,20 @@ public static function unsetColumn($array, $column)

return $array;
}

/**
* Get the first element of an array
*
* @param array $array The input array.
*
* @return mixed|null
*/
public static function first($array)
{
if (count($array) === 0) {
return null;
}

return reset($array);
}
}

0 comments on commit 36087e5

Please sign in to comment.