@param object $entity

@return number

@throws AnnotationReaderException if the boost value is not numeric
347482
public function getEntityBoost($entity)
    {
        $annotation = $this->getClassAnnotation($entity, self::DOCUMENT_CLASS);

        if (!$annotation instanceof Document) {
            return 0;
        }

        $boostValue = $annotation->getBoost();
        if (!is_numeric($boostValue)) {
            throw new AnnotationReaderException(sprintf('Invalid boost value "%s" in class "%s" configured', $boostValue, get_class($entity)));
        }

        if ($boostValue === 0) {
            return null;
        }

        return $boostValue;
    }
681456
public function getEntityColumnType($entity, $property) {
        $classRef = new \ReflectionClass($entity);
        if ($classRef->hasProperty($property)) {
            $propertyRef = $classRef->getProperty($property);
            $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Column');
        } else {
            /** Can not find the property on the class. Check the all the Column annotation */
            foreach ($classRef->getProperties() as $propertyRef) {
                $columnRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Column');
                if ($columnRef->name == $property) {
                    break;
                } else {
                    $columnRef = null;
                }
            }
        }
        if ($columnRef === null) {
            $idRef = $this->annoReader->getPropertyAnnotation($propertyRef, 'Doctrine\ORM\Mapping\Id');
            if ($idRef !== null) {
                return "int";
            } else {
                return "string";
            }
        } else {
            return $this->getColumnType($columnRef->type);
        }
    }
1120449
private function getTranslatableEntityConfiguration($entity)
    {
        $entityNamespace = get_class($entity);
        $classStack = $this->getNamespacesFromClass($entityNamespace);

        foreach ($classStack as $classNamespace) {
            if (array_key_exists($classNamespace, $this->translationConfiguration)) {
                return $this->translationConfiguration[$classNamespace];
            }
        }

        return null;
    }
131651
private function process($entity)
    {
        $entityClass = get_class($entity);

        if (false === ($entity instanceof HasOptionalFieldsEntityInterface)) {
            return false;
        }

        $reflectionClass = new \ReflectionClass($entityClass);
        foreach ($reflectionClass->getProperties() as $reflectionProperty) {
            /** @var Optional $propertyAnnotation */
            $propertyAnnotation = $this->getReader()->getPropertyAnnotation($reflectionProperty, Optional::class);
            if (null === $propertyAnnotation) {
                continue;
            }

            $default = $this->getDefault($reflectionProperty, $propertyAnnotation->default);
            $reflectionProperty->setAccessible(true);

            if (null === $reflectionProperty->getValue($entity)) {
                $reflectionProperty->setValue($entity, $default);
            }
        }

        return true;
    }
466297
public function get($entity)
    {
        $key = $this->mapping['fieldname'];
        $valueMethod = 'get' . ucfirst($key);
        $value = $entity->$valueMethod();

        return $value;
    }
1193599
private function loadDelegates($entity)
    {
        if (!$this instanceof LazyLoaderInterface) {
            return $entity;
        }
        if (!$entity instanceof LazyPropertiesInterface) {
            throw new \InvalidArgumentException(sprintf('%s objects cannot be hydrated with properties loading delegates without implementing %s.',
                get_class($entity),
                LazyPropertiesInterface::class
            ));
        }

        // global handler (deprecated)
        if (isset($proxies[$loaderClass = static::class])) {
            @trigger_error(
                sprintf('Global loader delegate is deprecated and will be removed in 1.6. Make "%s" loader invokable instead, entity to handle is given at first parameter.',
                    static::class
                ),
                E_USER_DEPRECATED
            );
            $proxies[$loaderClass]($entity);
            unset($proxies[$loaderClass]);
        }

        // define delegates into object
        $entity->registerLoaders(
            $this->getLoadingDelegates()
        );

        // global handler
        if (is_callable($this)) {
            $this($entity);
        }

        return $entity;
    }
899822
private function getContentFromEntity( $entity ) {
		switch ( $entity->getType() ) {
			case Item::ENTITY_TYPE:
				return new ItemContent( $entity );
			case Property::ENTITY_TYPE:
				return new PropertyContent( $entity );
			default:
				throw new RuntimeException( 'I cant get a content for this type of entity' );
		}
	}
1117043
public function validateEntity($entity)
    {
        $description = $entity->getEntityDescription();

        //if entity is persisted only look at the modified
        //properties
        if ($entity->isModified()) {
            $properties = array_intersect_key($description->getProperty(), AnConfig::unbox($entity->getModifiedData()));
        } else {
            $properties = $description->getProperty();
        }

        foreach ($properties as $property) {
            $value = $entity->get($property->getName());
            $entity->getValidator()->validateData($entity, $property, $value);
        }

        return $entity->getErrors()->count() === 0;
    }
1323694
protected function _getEntityClassName($entity)
    {
        if (is_object($entity)) {
            $className = get_class($entity);
        } else {
            $className = $entity;
        }
        return $className;
    }
152810
protected function entityToString($entity)
    {
        return method_exists($entity, '__toString') ? (string) $entity : get_class($entity) . '@' . spl_object_hash($entity);
    }
498225
public function getNextRevisionNumberForEntity(EntityInterface $entity): int
    {
        $revision = 1;
        $last = $this->find()
            ->select('revision')
            ->where([
                'model' => $this->getEntityModel($entity),
                'foreign_key' => $entity->id
            ])
            ->order(['revision DESC'])
            ->hydrate(false)
            ->first();

        if (isset($last['revision'])) {
            $revision = $last['revision'] + 1;
        }

        return $revision;
    }
682431
protected function _getTitle($entity)
    {
        $title = $entity->page_title;
        if ((bool)$entity->display_page_title_suffix) {
            $title .= WasabiCms::titleSuffix();
        }
        return $title;
    }
104292
public function getMetaData($entity)
    {
        $propertyAnnotations = [];
        $result = new \stdClass;
        $class = new \ReflectionClass($entity);
        $classAnnotations = $this->_reader->getClassAnnotations($class);
        foreach ($class->getProperties() as $key => $value) {
            $annotation = $this->_reader->getPropertyAnnotations(new \ReflectionProperty($entity, $value->name));
            if (count($annotation)) {
                $propertyAnnotations[$value->name] = array_pop($annotation);
            }
        }

        foreach ($classAnnotations as $annotation) {
            if ($annotation instanceof \MercadoPago\Annotation\RestMethod) {
                $result->methods[$annotation->method] = get_object_vars($annotation);
            }
            if ($annotation instanceof \MercadoPago\Annotation\RequestParam) {
                $result->params[] = $annotation->param;
            }
            if ($annotation instanceof \MercadoPago\Annotation\DenyDynamicAttribute) {
                $result->denyDynamicAttribute = true;
            }
        }

        foreach ($propertyAnnotations as $key => $annotation) {
            if ($annotation instanceof \MercadoPago\Annotation\Attribute) {
                $result->attributes[$key] = get_object_vars($annotation);
            }
        }

        return $result;
    }
95525
public function reduce($entity)
    {
        $entityClass        = get_class($entity);
        $meta               = $this->getMeta($entityClass);

        $reflection = new \ReflectionClass($entity);
        $properties = [];

        foreach ($meta->fields as $name => $field) {
            $varName = $field->propertyName($field->name);
            $colName = $field->columnName($field->name);

            $value = null;

            if ($reflection->hasProperty($varName)) {
                $property = $reflection->getProperty($varName);
                $property->setAccessible(true);
                $value = $property->getValue($entity);

                switch ($field->type) {
                    case 'int':
                    case 'integer':
                        $value = (integer)$value;
                        break;

                    case 'float':
                        $value = (float)$value;
                        break;

                    case 'boolean':
                        $value = (integer)in_array($value, ['true', 'yes', 'on']);
                        break;

                    case 'json':
                        $value = json_encode($value);
                        break;

                    case 'datetime':
                        if ($value == '0000-00-00 00:00:00') {
                            $value = '1001-01-01 00:00:00';
                        }
                        break;

                    default:
                        // Leave the value alone
                        break;
                }
            }

            $properties[$colName] = $value;
        }

        return $properties;
    }
642349
protected function getEntityTable($entity)
    {
        if (!$entity instanceof EntityInterface) {
            $entity = $this->getEntityClass($entity);
        }
        return $this->tablePrefix . $entity::getTable() . $this->tableSuffix;
    }
1360591
public static function readMethod( $method , $annotation = null ) {

		$ref = $method instanceof ReflectionMethod ? $method : new ReflectionMethod( $method[0] , $method[1] );

		return $annotation ? static::reader()->getMethodAnnotation( $ref , $annotation ) : static::reader()->getMethodAnnotations( $ref );

	}
1339681
public function getCount(EntityManager $em, Request $request)
	{
		$stmt = $this->buildCountQuery($em, $request);
		$stmt->execute();
		return (int) $stmt->fetchColumn();
	}