/** * @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; }
/** * @param Property $property * @param $oldEntity * @param $newEntity * @return bool */ private function isDifferent(Property $property, $oldEntity, $newEntity) { return $this->propertyValueComparer->hasDifferentValue($property, $newEntity, $oldEntity); }