示例#1
0
 /**
  * @param $firstEntity
  * @param $secondEntity
  * @return bool
  * @throws InvalidArgumentException
  */
 public function areEqual($firstEntity, $secondEntity)
 {
     $entityDefinition = $this->definitions->getDefinition($firstEntity);
     if (!$entityDefinition->fitsFor($secondEntity)) {
         throw new InvalidArgumentException("You can't compare entities of different type.");
     }
     foreach ($entityDefinition->getObservedProperties() as $property) {
         if ($this->propertyValueComparer->hasDifferentValue($property, $firstEntity, $secondEntity)) {
             return false;
         }
     }
     return true;
 }
示例#2
0
 /**
  * @param Property $property
  * @param $oldEntity
  * @param $newEntity
  * @return bool
  */
 private function isDifferent(Property $property, $oldEntity, $newEntity)
 {
     return $this->propertyValueComparer->hasDifferentValue($property, $newEntity, $oldEntity);
 }