Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * ArrayUtils
- *
- * @author Dustin Breuer <developer@thedust.in>
- * @license 2015 MIT
- */
- namespace TheDusti\Util;
- /**
- * Class ArrayUtils
- *
- * @package TheDusti\Util
- * @author Dustin Breuer <developer@thedust.in>
- */
- abstract class ArrayUtils {
- /**
- * Test whether some Elements are <i>TRUE</i>
- *
- * @param array $aArr
- * @param callable $cTestFunc
- *
- * @return bool
- */
- public static function some(array $aArr, callable $cTestFunc = null){
- if($cTestFunc !== null){
- $aArr = array_map($cTestFunc, $aArr);
- }
- foreach($aArr as $mElement){
- if($mElement){
- return true;
- }
- }
- return false;
- }
- /**
- * Test whether all Elements are <i>TRUE</i>
- *
- * @param array $aArr
- * @param callable $cTestFunc
- *
- * @return bool
- */
- public static function every(array $aArr, callable $cTestFunc = null){
- if($cTestFunc !== null){
- $aArr = array_map($cTestFunc, $aArr);
- }
- foreach($aArr as $mElement){
- if(!$mElement){
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement