private function isValidResult($result, $entity)
    {
        return 0 === \count($result)
            || (1 === \count($result)
                && $entity === ($result instanceof \Iterator ? $result->current() : current($result)));
    }
private function isValidResult($result, $entity)
    {
        return 0 === \count($result)
            || (1 === \count($result)
                && $entity === ($result instanceof \Iterator ? $result->current() : current($result)));
    }
private function isValidResult ( $ result , $ entity ) { return 0 === \ count ( $ result ) || ( 1 === \ count ( $ result ) && $ entity === ( $ result instanceof \ Iterator ? $ result -> current ( ) : current ( $ result ) ) ) ; }
Check if the result is valid.

If no entity matched the query criteria or a single entity matched,
which is the same as the entity being validated, the criteria is
unique.

@param array|\Iterator $result
@param object          $entity

@return bool
Check if the result is valid .