protected function castToArray(&$subject)
    {
        if (is_array($subject) === false) {
            if (Arr::accessible($subject) === false) {
                $subject = new Collection($subject);
            }
            $subject = $subject instanceof Arrayable ? $subject->toArray() : (array)$subject;
        }
        return $this;
    }
protected function castToArray(&$subject)
    {
        if (is_array($subject) === false) {
            if (Arr::accessible($subject) === false) {
                $subject = new Collection($subject);
            }
            $subject = $subject instanceof Arrayable ? $subject->toArray() : (array)$subject;
        }
        return $this;
    }
protected function castToArray ( & $ subject ) { if ( is_array ( $ subject ) === false ) { if ( Arr :: accessible ( $ subject ) === false ) { $ subject = new Collection ( $ subject ) ; } $ subject = $ subject instanceof Arrayable ? $ subject -> toArray ( ) : ( array ) $ subject ; } return $ this ; }
Because of the enumerable ways non-arrays can act like arrays, we create a
Collection, which has useful normalizer functions, and return that as an array.

@param mixed $subject
@return $this
Because of the enumerable ways non - arrays can act like arrays we create a Collection which has useful normalizer functions and return that as an array .