public function find($id, bool $getRelations = null): ? Entity
    {
        if (! \is_string($id) && ! \is_int($id)) {
            throw new InvalidArgumentException('ID should be an int or string only.');
        }

        return $this->findBy(
                [$this->entity::getIdField() => $id],
                null,
                null,
                null,
                null,
                $getRelations
            )[0]
            ?? null;
    }
public function find($id, bool $getRelations = null): ? Entity
    {
        if (! \is_string($id) && ! \is_int($id)) {
            throw new InvalidArgumentException('ID should be an int or string only.');
        }

        return $this->findBy(
                [$this->entity::getIdField() => $id],
                null,
                null,
                null,
                null,
                $getRelations
            )[0]
            ?? null;
    }
public function find ( $ id , bool $ getRelations = null ) : ? Entity { if ( ! \ is_string ( $ id ) && ! \ is_int ( $ id ) ) { throw new InvalidArgumentException ( 'ID should be an int or string only.' ) ; } return $ this -> findBy ( [ $ this -> entity :: getIdField ( ) => $ id ] , null , null , null , null , $ getRelations ) [ 0 ] ?? null ; }
Find a single entity given its id.

@param string|int $id
@param bool|null  $getRelations

@throws InvalidArgumentException If id is not a string or int

@return \Valkyrja\ORM\Entity|null
Find a single entity given its id .