src/Serializer/Serializer.php
public function normalize($obj)
    {
        $properties = $this->getClassProperties(get_class($obj));
        $data = [];
        foreach ($properties as $name => $prop) {
            if (isset($prop['getter'])) {
                $getter = $prop['getter'];
                $value = $obj->$getter();
            } else {
                $key = $prop['name'];
                $value = $obj->$key;
            }
            if (isset($prop['type'])) {
                if ($prop['type'] === 'array') {
                    $value = array_map(function ($elem) use ($prop) {
                        return $this->normalize($elem);
                    }, $value);
                } else {
                    $value = $this->normalize($value);
                }
            }
            if (isset($prop['serializeName'])) {
                $name = $prop['serializeName'];
            }
            $data[$name] = $value;
        }
        return $data;
    }
public function normalize($obj)
    {
        $properties = $this->getClassProperties(get_class($obj));
        $data = [];
        foreach ($properties as $name => $prop) {
            if (isset($prop['getter'])) {
                $getter = $prop['getter'];
                $value = $obj->$getter();
            } else {
                $key = $prop['name'];
                $value = $obj->$key;
            }
            if (isset($prop['type'])) {
                if ($prop['type'] === 'array') {
                    $value = array_map(function ($elem) use ($prop) {
                        return $this->normalize($elem);
                    }, $value);
                } else {
                    $value = $this->normalize($value);
                }
            }
            if (isset($prop['serializeName'])) {
                $name = $prop['serializeName'];
            }
            $data[$name] = $value;
        }
        return $data;
    }
public function normalize ( $ obj ) { $ properties = $ this -> getClassProperties ( get_class ( $ obj ) ) ; $ data = [ ] ; foreach ( $ properties as $ name => $ prop ) { if ( isset ( $ prop [ 'getter' ] ) ) { $ getter = $ prop [ 'getter' ] ; $ value = $ obj -> $ getter ( ) ; } else { $ key = $ prop [ 'name' ] ; $ value = $ obj -> $ key ; } if ( isset ( $ prop [ 'type' ] ) ) { if ( $ prop [ 'type' ] === 'array' ) { $ value = array_map ( function ( $ elem ) use ( $ prop ) { return $ this -> normalize ( $ elem ) ; } , $ value ) ; } else { $ value = $ this -> normalize ( $ value ) ; } } if ( isset ( $ prop [ 'serializeName' ] ) ) { $ name = $ prop [ 'serializeName' ] ; } $ data [ $ name ] = $ value ; } return $ data ; }
Normalizes the object into an array of scalars|arrays.
Normalizes the object into an array of scalars|arrays .