src/Entity.php
public function jsonSerialize()
    {
        $output = [];
        foreach ($this::getReflection()->getProperties() as $propertyName => $property) {

            $value = $this->{$propertyName};
            if ($value instanceof Entity\Collection || $value instanceof Entity) {
                $output[$propertyName] = $value->jsonSerialize();
            } elseif ($value instanceof \DateTime
                && $property->getType() === Entity\Reflection\Property::TYPE_DATE
            ) {
                $output[$propertyName] = (array) $value;
                $output[$propertyName]["date"] = $value->format(self::$dateFormat);
            } else {
                $output[$propertyName] = $value;
            }
        }

        return $output;
    }
public function jsonSerialize()
    {
        $output = [];
        foreach ($this::getReflection()->getProperties() as $propertyName => $property) {

            $value = $this->{$propertyName};
            if ($value instanceof Entity\Collection || $value instanceof Entity) {
                $output[$propertyName] = $value->jsonSerialize();
            } elseif ($value instanceof \DateTime
                && $property->getType() === Entity\Reflection\Property::TYPE_DATE
            ) {
                $output[$propertyName] = (array) $value;
                $output[$propertyName]["date"] = $value->format(self::$dateFormat);
            } else {
                $output[$propertyName] = $value;
            }
        }

        return $output;
    }
public function jsonSerialize ( ) { $ output = [ ] ; foreach ( $ this :: getReflection ( ) -> getProperties ( ) as $ propertyName => $ property ) { $ value = $ this -> { $ propertyName } ; if ( $ value instanceof Entity \ Collection || $ value instanceof Entity ) { $ output [ $ propertyName ] = $ value -> jsonSerialize ( ) ; } elseif ( $ value instanceof \ DateTime && $ property -> getType ( ) === Entity \ Reflection \ Property :: TYPE_DATE ) { $ output [ $ propertyName ] = ( array ) $ value ; $ output [ $ propertyName ] [ "date" ] = $ value -> format ( self :: $ dateFormat ) ; } else { $ output [ $ propertyName ] = $ value ; } } return $ output ; }
Gets data which should be serialized to JSON

@return array
Gets data which should be serialized to JSON