Split attribute model into primitive types
This commit is contained in:
parent
2fbc434e25
commit
3172f3073c
|
@ -28,25 +28,12 @@ class Attribute extends Model
|
|||
'default' => '',
|
||||
'example' => 'string',
|
||||
])
|
||||
->addRule('size', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Attribute size.',
|
||||
'default' => 0,
|
||||
'example' => 128,
|
||||
])
|
||||
->addRule('required', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is attribute required?',
|
||||
'default' => false,
|
||||
'example' => true,
|
||||
])
|
||||
->addRule('signed', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is attribute signed?',
|
||||
'default' => true,
|
||||
'example' => true,
|
||||
'required' => false,
|
||||
])
|
||||
->addRule('array', [
|
||||
'type' => self::TYPE_BOOLEAN,
|
||||
'description' => 'Is attribute an array?',
|
||||
|
@ -54,14 +41,6 @@ class Attribute extends Model
|
|||
'example' => false,
|
||||
'required' => false
|
||||
])
|
||||
->addRule('filters', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Attribute filters.',
|
||||
'default' => [],
|
||||
'example' => [],
|
||||
'array' => true,
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
|
|
51
src/Appwrite/Utopia/Response/Model/AttributeFloat.php
Normal file
51
src/Appwrite/Utopia/Response/Model/AttributeFloat.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model\Attribute;
|
||||
|
||||
class AttributeFloat extends Attribute
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('min', [
|
||||
'type' => self::TYPE_FLOAT,
|
||||
'description' => 'Minimum value to enforce on new documents.',
|
||||
'default' => null,
|
||||
'example' => 0.5,
|
||||
'array' => false,
|
||||
'required' => false,
|
||||
])
|
||||
->addRule('max', [
|
||||
'type' => self::TYPE_FLOAT,
|
||||
'description' => 'Minimum value to enforce on new documents.',
|
||||
'default' => null,
|
||||
'example' => 2.5,
|
||||
'array' => false,
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Float';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_FLOAT;
|
||||
}
|
||||
}
|
51
src/Appwrite/Utopia/Response/Model/AttributeInteger.php
Normal file
51
src/Appwrite/Utopia/Response/Model/AttributeInteger.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model\Attribute;
|
||||
|
||||
class AttributeInteger extends Attribute
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('min', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Minimum value to enforce on new documents.',
|
||||
'default' => null,
|
||||
'example' => 0,
|
||||
'array' => false,
|
||||
'required' => false,
|
||||
])
|
||||
->addRule('max', [
|
||||
'type' => self::TYPE_INTEGER,
|
||||
'description' => 'Minimum value to enforce on new documents.',
|
||||
'default' => null,
|
||||
'example' => 10,
|
||||
'array' => false,
|
||||
'required' => false,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'Integer';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_INTEGER;
|
||||
}
|
||||
}
|
41
src/Appwrite/Utopia/Response/Model/AttributeString.php
Normal file
41
src/Appwrite/Utopia/Response/Model/AttributeString.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Appwrite\Utopia\Response\Model;
|
||||
|
||||
use Appwrite\Utopia\Response;
|
||||
use Appwrite\Utopia\Response\Model\Attribute;
|
||||
|
||||
class AttributeString extends Attribute
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this
|
||||
->addRule('size', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Attribute size.',
|
||||
'default' => 0,
|
||||
'example' => 128,
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName():string
|
||||
{
|
||||
return 'String';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Collection
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType():string
|
||||
{
|
||||
return Response::MODEL_ATTRIBUTE_STRING;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue