Skip to content

Commit

Permalink
Rename method and use saved/deleted event for consistency with other …
Browse files Browse the repository at this point in the history
…observer
  • Loading branch information
stevebauman committed Oct 6, 2023
1 parent 54411fd commit d4dc86d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Testing/VirtualAttributeValueObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
class VirtualAttributeValueObserver
{
/**
* The virtual attributes to update when changed.
* The attributes to watch with its attribute to update.
*/
public static array $attributes = [
'member' => 'memberof',
];

/**
* Handle updating the virtual attribute in the related model.
* Handle updating the virtual attribute in the related model(s).
*/
public function saving(LdapObjectAttributeValue $model): void
public function saved(LdapObjectAttributeValue $model): void
{
if (! $this->hasVirtualAttribute($model->attribute->name)) {
if (! $this->isWatchedAttribute($model->attribute->name)) {
return;
}

Expand All @@ -36,11 +36,11 @@ public function saving(LdapObjectAttributeValue $model): void
}

/**
* Handle deleting the virtual attribute in the related model.
* Handle deleting the virtual attribute in the related model(s).
*/
public function deleting(LdapObjectAttributeValue $model): void
public function deleted(LdapObjectAttributeValue $model): void
{
if (! $this->hasVirtualAttribute($model->attribute->name)) {
if (! $this->isWatchedAttribute($model->attribute->name)) {
return;
}

Expand All @@ -58,9 +58,9 @@ public function deleting(LdapObjectAttributeValue $model): void
}

/**
* Determine if a virtual attribute exists for the given attribute.
* Determine if the attribute is a watched attribute.
*/
protected function hasVirtualAttribute(string $attribute): bool
protected function isWatchedAttribute(string $attribute): bool
{
return array_key_exists($attribute, static::$attributes);
}
Expand Down

0 comments on commit d4dc86d

Please sign in to comment.