src/Rxnet/Contract/DataContainerTrait.php
protected function normalize($payload)
    {
        $data = get_object_vars($payload);
        foreach ($data as $k => $v) {
            if ($v instanceof \DateTime) {
                $payload->$k = $v->format('c');
                continue;
            }
            if (is_object($v)) {
                $payload->$k = $this->normalize($v);
                continue;
            }
        }
        return $payload;
    }
protected function normalize($payload)
    {
        $data = get_object_vars($payload);
        foreach ($data as $k => $v) {
            if ($v instanceof \DateTime) {
                $payload->$k = $v->format('c');
                continue;
            }
            if (is_object($v)) {
                $payload->$k = $this->normalize($v);
                continue;
            }
        }
        return $payload;
    }
protected function normalize ( $ payload ) { $ data = get_object_vars ( $ payload ) ; foreach ( $ data as $ k => $ v ) { if ( $ v instanceof \ DateTime ) { $ payload -> $ k = $ v -> format ( 'c' ) ; continue ; } if ( is_object ( $ v ) ) { $ payload -> $ k = $ this -> normalize ( $ v ) ; continue ; } } return $ payload ; }
Transform nested sub objects to string if needed
Only DateTime or Carbon now
@param object $payload
@return object
Transform nested sub objects to string if needed Only DateTime or Carbon now