Pramda\Exception::assertArray PHP Метод

assertArray() публичный статический Метод

public static assertArray ( $collection )
$collection
    public static function assertArray($collection)
    {
        if (!is_array($collection)) {
            throw new \InvalidArgumentException("Argument is not an array");
        }
    }

Usage Example

Пример #1
0
 /**
  * @return mixed|callable
  */
 public static function slice()
 {
     $args = func_get_args();
     /**
      * Returns the elements of the given list from start (inclusive) to end (exclusive).
      * Curried version of array_slice
      *
      * @category List
      *
      * @param int   $start
      * @param int   $end
      * @param array $arr
      *
      * @return array
      * @throws Exception
      */
     $_slice = function ($start, $end, $arr) {
         $arr = P::toArray($arr);
         Exception::assertArray($arr);
         Exception::assertInteger($start);
         if ($end === NULL) {
             $end = count($arr);
         }
         Exception::assertInteger($end);
         return array_slice($arr, $start, $end - $start);
     };
     return call_user_func_array(self::curry3($_slice), $args);
 }