/** * @param Entity $entity * @param array $excludedFields * @return bool */ public function compare(Entity $entity, array $excludedFields = null) { if (!$entity instanceof $this) { throw new InvalidArgumentException('Argument $entity has wrong instance type.'); } $_this = $this->getRowData(); $e = $entity->getRowData(); if (isset($excludedFields)) { $excludedFields = array_flip($excludedFields); foreach ($excludedFields as $fieldName => $v) { if (array_key_exists($fieldName, $_this)) { unset($_this[$fieldName]); } if (array_key_exists($fieldName, $e)) { unset($e[$fieldName]); } } } return md5(json_encode($_this)) === md5(json_encode($e)); }