Skip to content

Loss of functionality by casting to array, should be changed. #1033

Open
@OzanKurt

Description

@OzanKurt

In src/Helper.php, why would I cast a useful object to an array and lose all the functionality they provide?

For example:

I have a scheduled_at column, which should be rendered as d-m-Y H:i, and I can't use ->format() on it because it has been cast to an array from a Carbon\Carbon object.

    /**
     * Cast the parameter into an array.
     *
     * @param mixed $param
     * @return array
     */
    public static function castToArray($param)
    {
        if ($param instanceof \stdClass) {
            $param = (array) $param;

            return $param;
        }

        if ($param instanceof Arrayable) {
            return $param->toArray();
        }

        return $param;
    }

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions