| @@ 8-80 (lines=73) @@ | ||
| 5 | use Isolate\UnitOfWork\Entity\Definition\Property; |
|
| 6 | use Isolate\UnitOfWork\Entity\Value\Change; |
|
| 7 | ||
| 8 | final class NewEntity implements Change |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var mixed |
|
| 12 | */ |
|
| 13 | private $newValue; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @var Property |
|
| 17 | */ |
|
| 18 | private $property; |
|
| 19 | ||
| 20 | ||
| 21 | /** |
|
| 22 | * @var boolean |
|
| 23 | */ |
|
| 24 | private $isPersisted; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param Property $property |
|
| 28 | * @param $newValue |
|
| 29 | * @param boolean $isPersisted |
|
| 30 | */ |
|
| 31 | public function __construct(Property $property, $newValue, $isPersisted) |
|
| 32 | { |
|
| 33 | $this->property = $property; |
|
| 34 | $this->newValue = $newValue; |
|
| 35 | $this->isPersisted = (boolean) $isPersisted; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * @return mixed |
|
| 40 | */ |
|
| 41 | public function getOriginValue() |
|
| 42 | { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @return mixed |
|
| 48 | */ |
|
| 49 | public function getNewValue() |
|
| 50 | { |
|
| 51 | return $this->newValue; |
|
| 52 | } |
|
| 53 | ||
| 54 | /** |
|
| 55 | * @return Property |
|
| 56 | */ |
|
| 57 | public function getProperty() |
|
| 58 | { |
|
| 59 | return $this->property; |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @return boolean |
|
| 64 | * |
|
| 65 | * @api |
|
| 66 | */ |
|
| 67 | public function isPersisted() |
|
| 68 | { |
|
| 69 | return $this->isPersisted; |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @param $propertyName |
|
| 74 | * @return bool |
|
| 75 | */ |
|
| 76 | public function isFor($propertyName) |
|
| 77 | { |
|
| 78 | return $this->property->getName() === $propertyName; |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||
| @@ 8-69 (lines=62) @@ | ||
| 5 | use Isolate\UnitOfWork\Entity\Definition\Property; |
|
| 6 | use Isolate\UnitOfWork\Entity\Value\Change; |
|
| 7 | ||
| 8 | final class ScalarChange implements Change |
|
| 9 | { |
|
| 10 | /** |
|
| 11 | * @var mixed |
|
| 12 | */ |
|
| 13 | private $originValue; |
|
| 14 | ||
| 15 | /** |
|
| 16 | * @var mixed |
|
| 17 | */ |
|
| 18 | private $newValue; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * @var Property |
|
| 22 | */ |
|
| 23 | private $property; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * @param Property $property |
|
| 27 | * @param $originValue |
|
| 28 | * @param $newValue |
|
| 29 | */ |
|
| 30 | public function __construct(Property $property, $originValue, $newValue) |
|
| 31 | { |
|
| 32 | $this->property = $property; |
|
| 33 | $this->originValue = $originValue; |
|
| 34 | $this->newValue = $newValue; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * @return mixed |
|
| 39 | */ |
|
| 40 | public function getOriginValue() |
|
| 41 | { |
|
| 42 | return $this->originValue; |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @return mixed |
|
| 47 | */ |
|
| 48 | public function getNewValue() |
|
| 49 | { |
|
| 50 | return $this->newValue; |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return Property |
|
| 55 | */ |
|
| 56 | public function getProperty() |
|
| 57 | { |
|
| 58 | return $this->property; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @param $propertyName |
|
| 63 | * @return bool |
|
| 64 | */ |
|
| 65 | public function isFor($propertyName) |
|
| 66 | { |
|
| 67 | return $this->property->getName() === $propertyName; |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||