Permalink
Browse files

some changes

  • Loading branch information...
1 parent 2d9baf9 commit e3b020ca065624352180df4ac6f417b163e50c7e @pablodip pablodip committed Mar 7, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 Validator/Constraint/UniqueDocumentValidator.php
@@ -50,13 +50,13 @@ public function isValid($value, Constraint $constraint)
$caseInsensitive = $this->parseCaseInsensitive($constraint->caseInsensitive);
$query = $this->createQuery($document, $fields, $caseInsensitive);
- $nbResults = $query->count();
+ $numberResults = $query->count();
- if (0 === $nbResults) {
+ if (0 === $numberResults) {
return true;
}
- if (1 === $nbResults) {
+ if (1 === $numberResults) {
$result = $query->one();
if ($result === $document) {
return true;
@@ -81,16 +81,16 @@ private function parseDocument($document)
private function parseFields($fields)
{
- if (!is_array($fields) && !is_string($fields)) {
+ if (is_string($fields)) {
+ $fields = array($fields);
+ } elseif (is_array($fields)) {
+ if (0 === count($fields)) {
+ throw new ConstraintDefinitionException('At least one field has to be specified.');
+ }
+ } else {
throw new UnexpectedTypeException($fields, 'array');
}
- $fields = (array) $fields;
-
- if (0 === count($fields)) {
- throw new ConstraintDefinitionException('At least one field has to be specified.');
- }
-
return $fields;
}

0 comments on commit e3b020c

Please sign in to comment.