From af2e64ef7b65b7852b3be8bc83135c57d9c2713a Mon Sep 17 00:00:00 2001 From: kodumbeats Date: Tue, 24 Aug 2021 10:31:02 -0400 Subject: [PATCH] Construct parent models to properly inherit rules --- .../Response/Model/AttributeBoolean.php | 37 ++----------------- .../Utopia/Response/Model/AttributeEmail.php | 33 +---------------- .../Utopia/Response/Model/AttributeFloat.php | 33 +---------------- .../Utopia/Response/Model/AttributeIP.php | 33 +---------------- .../Response/Model/AttributeInteger.php | 36 ++---------------- .../Utopia/Response/Model/AttributeString.php | 33 +---------------- .../Utopia/Response/Model/AttributeURL.php | 33 +---------------- 7 files changed, 17 insertions(+), 221 deletions(-) diff --git a/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php b/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php index 93dbe57259..4076bc9eb4 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeBoolean.php @@ -3,44 +3,15 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; -use Appwrite\Utopia\Response\Model; +use Appwrite\Utopia\Response\Model\Attribute; -class AttributeBoolean extends Model +class AttributeBoolean extends Attribute { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('default', [ 'type' => self::TYPE_BOOLEAN, 'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.', diff --git a/src/Appwrite/Utopia/Response/Model/AttributeEmail.php b/src/Appwrite/Utopia/Response/Model/AttributeEmail.php index 861356df3e..1c058e6b04 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeEmail.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeEmail.php @@ -9,38 +9,9 @@ class AttributeEmail extends AttributeString { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('format', [ 'type' => self::TYPE_STRING, 'description' => 'String format.', diff --git a/src/Appwrite/Utopia/Response/Model/AttributeFloat.php b/src/Appwrite/Utopia/Response/Model/AttributeFloat.php index 85adbe2852..669aa4dd7e 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeFloat.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeFloat.php @@ -9,38 +9,9 @@ class AttributeFloat extends Attribute { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('format', [ 'type' => self::TYPE_FLOAT, 'description' => 'Float format.', diff --git a/src/Appwrite/Utopia/Response/Model/AttributeIP.php b/src/Appwrite/Utopia/Response/Model/AttributeIP.php index 36e000e15c..8272c2760a 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeIP.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeIP.php @@ -9,38 +9,9 @@ class AttributeIP extends AttributeString { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('format', [ 'type' => self::TYPE_STRING, 'description' => 'String format.', diff --git a/src/Appwrite/Utopia/Response/Model/AttributeInteger.php b/src/Appwrite/Utopia/Response/Model/AttributeInteger.php index 366ecd556f..d1ff6346f3 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeInteger.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeInteger.php @@ -9,38 +9,9 @@ class AttributeInteger extends Attribute { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('format', [ 'type' => self::TYPE_STRING, 'description' => 'Integer format.', @@ -65,8 +36,7 @@ class AttributeInteger extends Attribute } /** - * Get Name - * + * Get Name * * @return string */ public function getName():string diff --git a/src/Appwrite/Utopia/Response/Model/AttributeString.php b/src/Appwrite/Utopia/Response/Model/AttributeString.php index e8d1560391..22f7e52a3f 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeString.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeString.php @@ -9,38 +9,9 @@ class AttributeString extends Attribute { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('size', [ 'type' => self::TYPE_STRING, 'description' => 'Attribute size.', diff --git a/src/Appwrite/Utopia/Response/Model/AttributeURL.php b/src/Appwrite/Utopia/Response/Model/AttributeURL.php index 0d3365f3a2..3bb05f4fa9 100644 --- a/src/Appwrite/Utopia/Response/Model/AttributeURL.php +++ b/src/Appwrite/Utopia/Response/Model/AttributeURL.php @@ -9,38 +9,9 @@ class AttributeURL extends AttributeString { public function __construct() { + parent::__construct(); + $this - ->addRule('key', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute Key.', - 'default' => '', - 'example' => 'fullName', - ]) - ->addRule('type', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute type.', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('status', [ - 'type' => self::TYPE_STRING, - 'description' => 'Attribute status. Possible values: `available`, `processing`, `deleting`, or `failed`', - 'default' => '', - 'example' => 'string', - ]) - ->addRule('required', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute required?', - 'default' => false, - 'example' => true, - ]) - ->addRule('array', [ - 'type' => self::TYPE_BOOLEAN, - 'description' => 'Is attribute an array?', - 'default' => false, - 'example' => false, - 'require' => false - ]) ->addRule('format', [ 'type' => self::TYPE_STRING, 'description' => 'String format.',