public function cast($value)
    {
        if (isset($this->traversable) && !is_a($this->traversable, Traversable::class, true)) {
            return $this->dontCast($value, "{$this->traversable} is not Traversable");
        }

        $fn = 'cast' . ucfirst(gettype($value));
        $result = method_exists($this, $fn) ? $this->$fn($value) : (array)$value;

        if (!is_iterable($result)) {
            return $result;
        }

        //Commented out as there's no HandlerRepositoryInterface
        // if (isset($this->subtype)) {
        //     $result = $this->typecast instanceof HandlerRepositoryInterface
        //         ? $this->castEachWithHandler($result, $this->typecast)
        //         : $this->castEach($result);
        // }

        if (isset($this->subtype)) {
            $result = $this->castEach($result);
        }

        if (is_array($result) && isset($this->traversable)) {
            $class = $this->traversable;
            $result = new $class($result);
        }

        return $result;
    }
public function cast($value)
    {
        if (isset($this->traversable) && !is_a($this->traversable, Traversable::class, true)) {
            return $this->dontCast($value, "{$this->traversable} is not Traversable");
        }

        $fn = 'cast' . ucfirst(gettype($value));
        $result = method_exists($this, $fn) ? $this->$fn($value) : (array)$value;

        if (!is_iterable($result)) {
            return $result;
        }

        //Commented out as there's no HandlerRepositoryInterface
        // if (isset($this->subtype)) {
        //     $result = $this->typecast instanceof HandlerRepositoryInterface
        //         ? $this->castEachWithHandler($result, $this->typecast)
        //         : $this->castEach($result);
        // }

        if (isset($this->subtype)) {
            $result = $this->castEach($result);
        }

        if (is_array($result) && isset($this->traversable)) {
            $class = $this->traversable;
            $result = new $class($result);
        }

        return $result;
    }
public function cast ( $ value ) { if ( isset ( $ this -> traversable ) && ! is_a ( $ this -> traversable , Traversable :: class , true ) ) { return $ this -> dontCast ( $ value , "{$this->traversable} is not Traversable" ) ; } $ fn = 'cast' . ucfirst ( gettype ( $ value ) ) ; $ result = method_exists ( $ this , $ fn ) ? $ this -> $ fn ( $ value ) : ( array ) $ value ; if ( ! is_iterable ( $ result ) ) { return $ result ; } //Commented out as there's no HandlerRepositoryInterface // if (isset($this->subtype)) { //     $result = $this->typecast instanceof HandlerRepositoryInterface //         ? $this->castEachWithHandler($result, $this->typecast) //         : $this->castEach($result); // } if ( isset ( $ this -> subtype ) ) { $ result = $ this -> castEach ( $ result ) ; } if ( is_array ( $ result ) && isset ( $ this -> traversable ) ) { $ class = $ this -> traversable ; $ result = new $ class ( $ result ) ; } return $ result ; }
Cast value to an array

@param mixed $value
@return array|mixed
Cast value to an array