public static function objectToArray($source): array
    {
        $result = [];

        if (is_array($source)) {
            return $source;
        }

        if (!is_object($source)) {
            return $result;
        }

        $json = json_encode($source);
        if ($json === false) {
            return $result;
        }

        $array = json_decode($json, true);
        if ($array === null) {
            return $result;
        }
        $result = $array;

        return $result;
    }