public function toArray($filter = ReflectionProperty::IS_PROTECTED)
    {
        $objectArray = [];

        // Get all properties
        $ref = new ReflectionClass($this);
        $properties = $ref->getProperties($filter);
        foreach ($properties as $property) {
            $propertyName = $property->getName();
            if (isset($this->$propertyName)) {
                $objectArray[$propertyName] = $this->$propertyName;
            }
        }

        return $objectArray;
    }