From fe60f1102d80c1998e079347d307358eb5047649 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Thu, 14 Jul 2022 16:06:33 +0200 Subject: [PATCH] change sender to notString value object --- src/ValueObject/Sender.php | 2 +- src/ValueObject/StringValueObject.php | 12 ------------ src/ValueObject/ValueObject.php | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/ValueObject/Sender.php b/src/ValueObject/Sender.php index 1d95635..cec7896 100644 --- a/src/ValueObject/Sender.php +++ b/src/ValueObject/Sender.php @@ -24,7 +24,7 @@ use libphonenumber\NumberParseException; use libphonenumber\PhoneNumberFormat; use libphonenumber\PhoneNumberUtil; -class Sender extends StringValueObject +class Sender extends ValueObject { /** * @param string $number diff --git a/src/ValueObject/StringValueObject.php b/src/ValueObject/StringValueObject.php index 5fe8cf7..a0e58c2 100644 --- a/src/ValueObject/StringValueObject.php +++ b/src/ValueObject/StringValueObject.php @@ -19,13 +19,6 @@ use Assert\Assert; abstract class StringValueObject extends ValueObject { - public function __construct(string $number) - { - Assert::that($number)->notEmpty(); - - $this->value = $number; - } - public function __toString() { return $this->get(); @@ -35,9 +28,4 @@ abstract class StringValueObject extends ValueObject { return $this->value; } - - public function getFormatted() - { - return $this->get(); - } } diff --git a/src/ValueObject/ValueObject.php b/src/ValueObject/ValueObject.php index b140a3c..5a24217 100644 --- a/src/ValueObject/ValueObject.php +++ b/src/ValueObject/ValueObject.php @@ -15,7 +15,26 @@ declare(strict_types=1); namespace D3\LinkmobilityClient\ValueObject; +use Assert\Assert; + abstract class ValueObject { protected $value; + + public function __construct(string $number) + { + Assert::that($number)->notEmpty(); + + $this->value = $number; + } + + public function get() + { + return $this->value; + } + + public function getFormatted() + { + return $this->get(); + } }