2021-08-14 08:57:08 +12:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
|
|
|
use Appwrite\Utopia\Response\Model\Attribute;
|
|
|
|
|
|
|
|
class AttributeFloat extends Attribute
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
2021-08-25 02:31:02 +12:00
|
|
|
parent::__construct();
|
|
|
|
|
2021-08-14 08:57:08 +12:00
|
|
|
$this
|
2021-08-17 10:59:33 +12:00
|
|
|
->addRule('format', [
|
2021-08-14 08:57:08 +12:00
|
|
|
'type' => self::TYPE_FLOAT,
|
2021-08-17 10:59:33 +12:00
|
|
|
'description' => 'Float format.',
|
2021-08-14 08:57:08 +12:00
|
|
|
'default' => null,
|
2021-08-17 10:59:33 +12:00
|
|
|
'example' => \json_encode([
|
|
|
|
'name' => APP_DATABASE_ATTRIBUTE_FLOAT_RANGE,
|
|
|
|
'min' => 1.5,
|
|
|
|
'max' => 2.5,
|
|
|
|
]),
|
2021-08-14 08:57:08 +12:00
|
|
|
'array' => false,
|
2021-08-17 10:59:33 +12:00
|
|
|
'require' => false,
|
2021-08-14 08:57:08 +12:00
|
|
|
])
|
2021-08-17 08:06:27 +12:00
|
|
|
->addRule('default', [
|
|
|
|
'type' => self::TYPE_FLOAT,
|
|
|
|
'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.',
|
|
|
|
'default' => null,
|
|
|
|
'example' => 2.5,
|
|
|
|
'array' => false,
|
2021-08-17 10:59:33 +12:00
|
|
|
'require' => false,
|
2021-08-17 08:06:27 +12:00
|
|
|
])
|
2021-08-14 08:57:08 +12:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getName():string
|
|
|
|
{
|
2021-08-17 07:59:58 +12:00
|
|
|
return 'AttributeFloat';
|
2021-08-14 08:57:08 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Collection
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getType():string
|
|
|
|
{
|
2021-08-17 07:59:58 +12:00
|
|
|
return Response::MODEL_ATTRIBUTE_FLOAT;
|
2021-08-14 08:57:08 +12:00
|
|
|
}
|
|
|
|
}
|