propertyName = $propertyName; } /** * @inheritDoc */ public function getEvent() { return $this->propertyName . '.changed'; } /** * @inheritDoc */ public function hasChanged(object $prev, object $curr) { if (!property_exists($prev, $this->propertyName)) { return false; } if (!property_exists($curr, $this->propertyName)) { return false; } // internally save for later use $this->previousValue = $prev->{$this->propertyName}; $this->currentValue = $curr->{$this->propertyName}; return $this->checkChanges($this->previousValue, $this->currentValue); } /** * Internal changes detection. * * @param mixed $previousValue * @param mixed $currentValue * * @return bool */ protected function checkChanges($previousValue, $currentValue) { // check whether the property of the 2 elements are different return (bool) strcmp((string) $previousValue, (string) $currentValue); } /** * @inheritDoc */ final public function describe() { return $this->doDescribe($this->previousValue, $this->currentValue); } /** * Internal changes description. * * @param mixed $previousValue * @param mixed $currentValue * * @return string */ abstract protected function doDescribe($previousValue, $currentValue); /** * @inheritDoc */ public function getIcon() { return VikBookingIcons::i('pencil-alt'); } }