From 1a651fc718e8cae39e7bab6a5f41698d77809996 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 9 Jul 2016 10:05:33 +0200 Subject: [PATCH] Created base files for value types. --- src/engine/Types/Bool.php | 18 ++++++++++++ src/engine/Types/Double.php | 18 ++++++++++++ src/engine/Types/Email.php | 0 src/engine/Types/Int.php | 18 ++++++++++++ src/engine/Types/String.php | 18 ++++++++++++ src/engine/Types/Type.php | 47 ++++++++++++++++++++++++++++++++ src/engine/Types/UnsignedInt.php | 18 ++++++++++++ 7 files changed, 137 insertions(+) create mode 100644 src/engine/Types/Bool.php create mode 100644 src/engine/Types/Double.php create mode 100644 src/engine/Types/Email.php create mode 100644 src/engine/Types/Int.php create mode 100644 src/engine/Types/String.php create mode 100644 src/engine/Types/Type.php create mode 100644 src/engine/Types/UnsignedInt.php diff --git a/src/engine/Types/Bool.php b/src/engine/Types/Bool.php new file mode 100644 index 00000000..baa628b3 --- /dev/null +++ b/src/engine/Types/Bool.php @@ -0,0 +1,18 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +namespace \EA\Engine\Types; + +class Bool extends Type { + +} diff --git a/src/engine/Types/Double.php b/src/engine/Types/Double.php new file mode 100644 index 00000000..30d29ebc --- /dev/null +++ b/src/engine/Types/Double.php @@ -0,0 +1,18 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +namespace \EA\Engine\Types; + +class Double extends Type { + +} diff --git a/src/engine/Types/Email.php b/src/engine/Types/Email.php new file mode 100644 index 00000000..e69de29b diff --git a/src/engine/Types/Int.php b/src/engine/Types/Int.php new file mode 100644 index 00000000..b3bf8557 --- /dev/null +++ b/src/engine/Types/Int.php @@ -0,0 +1,18 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +namespace \EA\Engine\Types; + +class Int extends Type { + +} diff --git a/src/engine/Types/String.php b/src/engine/Types/String.php new file mode 100644 index 00000000..7fddb205 --- /dev/null +++ b/src/engine/Types/String.php @@ -0,0 +1,18 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +namespace \EA\Engine\Types; + +class String extends Type { + +} diff --git a/src/engine/Types/Type.php b/src/engine/Types/Type.php new file mode 100644 index 00000000..343857ca --- /dev/null +++ b/src/engine/Types/Type.php @@ -0,0 +1,47 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +namespace \EA\Engine\Types; + +/** + * Abstract Type Class + * + * This class needs to be extended by the type classes which must implement the validation logic. + */ +abstract class Type { + /** + * Class Constructor + * + * @param mixed $value The type value to be validated. + */ + public function __construct($value) { + $this->_validate($value); + $this->value = $value; + } + + /** + * Get the type value. + * + * @return mixed + */ + public function get() { + return $this->value; + } + + /** + * Implement the validation logic in the children classes. + * + * @throws \InvalidArgumentException If the validation fails. + */ + abstract protected function _validate(); +} diff --git a/src/engine/Types/UnsignedInt.php b/src/engine/Types/UnsignedInt.php new file mode 100644 index 00000000..e55b3fea --- /dev/null +++ b/src/engine/Types/UnsignedInt.php @@ -0,0 +1,18 @@ + + * @copyright Copyright (c) 2013 - 2016, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.2.0 + * ---------------------------------------------------------------------------- */ + +namespace \EA\Engine\Types; + +class UnsignedInt extends Int { + +}