private static function toArrayRecursive($object)
    {
        $output = get_object_vars($object);

        foreach ($output as $key => $value) {
            if ($value instanceof \DateTime) {
                $output[$key] = $value->format('c');
            } elseif (is_object($value)) {
                $output[$key] = static::toArrayRecursive($value);
            }
        }

        return $output;
    }