public function toArray($keepNullValue = false)
    {
        $reflection = new \ReflectionClass(static::class);

        $arrayData = [];
        foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
            $value = $property->getValue($this);

            // We don't want to add either static properties or when the value evaluates to regular empty but isn't a 0
            if ($property->isStatic()) {
                continue;
            }

            // If it's specifically decreed that it's a null value, we leave it in, which will set it to NULL in the db
            if (!$keepNullValue && $value === \Parable\ORM\Database::NULL_VALUE) {
                $value = null;
            }

            $arrayData[$property->getName()] = $value;
        }

        if ($this->getMapper()) {
            $arrayData = $this->toMappedArray($arrayData);
        }

        return $arrayData;
    }
public function toArray($keepNullValue = false)
    {
        $reflection = new \ReflectionClass(static::class);

        $arrayData = [];
        foreach ($reflection->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) {
            $value = $property->getValue($this);

            // We don't want to add either static properties or when the value evaluates to regular empty but isn't a 0
            if ($property->isStatic()) {
                continue;
            }

            // If it's specifically decreed that it's a null value, we leave it in, which will set it to NULL in the db
            if (!$keepNullValue && $value === \Parable\ORM\Database::NULL_VALUE) {
                $value = null;
            }

            $arrayData[$property->getName()] = $value;
        }

        if ($this->getMapper()) {
            $arrayData = $this->toMappedArray($arrayData);
        }

        return $arrayData;
    }
public function toArray ( $ keepNullValue = false ) { $ reflection = new \ ReflectionClass ( static :: class ) ; $ arrayData = [ ] ; foreach ( $ reflection -> getProperties ( \ ReflectionProperty :: IS_PUBLIC ) as $ property ) { $ value = $ property -> getValue ( $ this ) ; // We don't want to add either static properties or when the value evaluates to regular empty but isn't a 0 if ( $ property -> isStatic ( ) ) { continue ; } // If it's specifically decreed that it's a null value, we leave it in, which will set it to NULL in the db if ( ! $ keepNullValue && $ value === \ Parable \ ORM \ Database :: NULL_VALUE ) { $ value = null ; } $ arrayData [ $ property -> getName ( ) ] = $ value ; } if ( $ this -> getMapper ( ) ) { $ arrayData = $ this -> toMappedArray ( $ arrayData ) ; } return $ arrayData ; }
Generates an array of the current model, without the protected values.

@param bool $keepNullValue

@return array
@throws \ReflectionException
Generates an array of the current model without the protected values .