Skip to content

Instantly share code, notes, and snippets.

@mishfish
Created February 14, 2020 23:15
Show Gist options
  • Select an option

  • Save mishfish/7bdf6d617b02027d106f338f3e3a70a0 to your computer and use it in GitHub Desktop.

Select an option

Save mishfish/7bdf6d617b02027d106f338f3e3a70a0 to your computer and use it in GitHub Desktop.
<?php
class Entity
{
private $value;
public function changeValue(ValueChange $value): void
{
$this->value = $value->value($this);
}
}
class ValueChange
{
private $value;
private $someHeavyLogic;
public function validate(Entity $entity) : void
{
$this->someHeavyLogic->someMethod($entity);
}
public function value(Entity $entity)
{
$this->validate($entity);
return $this->value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment