public function forDataStore(): array
    {
        $properties = [];

        // Otherwise iterate through the properties array
        foreach (static::$properties as $property) {
            $value = $this->{$property};
            // Check if a type was set for this attribute
            $type = static::$propertyTypes[$property] ?? null;

            // If the type is object and the property isn't already an object
            if ($type === PropertyType::OBJECT && \is_object($value)) {
                // Unserialize the object
                $value = serialize($value);
            } // If the type is array and the property isn't already an array
            elseif ($type === PropertyType::ARRAY && \is_array($value)) {
                $value = \json_encode($value);
            }

            // And set each property to its value
            $properties[$property] = $value;
        }

        return $properties;
    }
public function forDataStore(): array
    {
        $properties = [];

        // Otherwise iterate through the properties array
        foreach (static::$properties as $property) {
            $value = $this->{$property};
            // Check if a type was set for this attribute
            $type = static::$propertyTypes[$property] ?? null;

            // If the type is object and the property isn't already an object
            if ($type === PropertyType::OBJECT && \is_object($value)) {
                // Unserialize the object
                $value = serialize($value);
            } // If the type is array and the property isn't already an array
            elseif ($type === PropertyType::ARRAY && \is_array($value)) {
                $value = \json_encode($value);
            }

            // And set each property to its value
            $properties[$property] = $value;
        }

        return $properties;
    }
public function forDataStore ( ) : array { $ properties = [ ] ; // Otherwise iterate through the properties array foreach ( static :: $ properties as $ property ) { $ value = $ this -> { $ property } ; // Check if a type was set for this attribute $ type = static :: $ propertyTypes [ $ property ] ?? null ; // If the type is object and the property isn't already an object if ( $ type === PropertyType :: OBJECT && \ is_object ( $ value ) ) { // Unserialize the object $ value = serialize ( $ value ) ; } // If the type is array and the property isn't already an array elseif ( $ type === PropertyType :: ARRAY && \ is_array ( $ value ) ) { $ value = \ json_encode ( $ value ) ; } // And set each property to its value $ properties [ $ property ] = $ value ; } return $ properties ; }
Get the entity as an array for saving to the data store.

@return array
Get the entity as an array for saving to the data store .