2021-08-16 20:01:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Appwrite\Utopia\Response\Model;
|
|
|
|
|
|
|
|
|
|
use Appwrite\Utopia\Response;
|
2021-08-24 14:31:02 +00:00
|
|
|
use Appwrite\Utopia\Response\Model\Attribute;
|
2021-08-16 20:01:20 +00:00
|
|
|
|
2021-08-24 14:31:02 +00:00
|
|
|
class AttributeBoolean extends Attribute
|
2021-08-16 20:01:20 +00:00
|
|
|
{
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
2021-08-24 14:31:02 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
|
2021-08-16 20:01:20 +00:00
|
|
|
$this
|
2022-03-14 06:03:55 +00:00
|
|
|
->addRule('key', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute Key.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'isEnabled',
|
|
|
|
|
])
|
|
|
|
|
->addRule('type', [
|
|
|
|
|
'type' => self::TYPE_STRING,
|
|
|
|
|
'description' => 'Attribute type.',
|
|
|
|
|
'default' => '',
|
|
|
|
|
'example' => 'boolean',
|
|
|
|
|
])
|
2021-08-16 20:06:27 +00:00
|
|
|
->addRule('default', [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN,
|
|
|
|
|
'description' => 'Default value for attribute when not provided. Cannot be set when attribute is required.',
|
|
|
|
|
'default' => null,
|
2022-09-02 23:19:20 +00:00
|
|
|
'required' => false,
|
2022-08-01 10:22:04 +00:00
|
|
|
'example' => false
|
2021-08-16 20:06:27 +00:00
|
|
|
])
|
2021-08-16 20:01:20 +00:00
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-14 08:26:16 +00:00
|
|
|
public array $conditions = [
|
|
|
|
|
'type' => self::TYPE_BOOLEAN
|
|
|
|
|
];
|
|
|
|
|
|
2021-08-16 20:01:20 +00:00
|
|
|
/**
|
|
|
|
|
* Get Name
|
2022-05-23 14:54:50 +00:00
|
|
|
*
|
2021-08-16 20:01:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getName(): string
|
2021-08-16 20:01:20 +00:00
|
|
|
{
|
|
|
|
|
return 'AttributeBoolean';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-09-15 15:17:09 +00:00
|
|
|
* Get Type
|
2022-05-23 14:54:50 +00:00
|
|
|
*
|
2021-08-16 20:01:20 +00:00
|
|
|
* @return string
|
|
|
|
|
*/
|
2022-05-23 14:54:50 +00:00
|
|
|
public function getType(): string
|
2021-08-16 20:01:20 +00:00
|
|
|
{
|
|
|
|
|
return Response::MODEL_ATTRIBUTE_BOOLEAN;
|
|
|
|
|
}
|
2022-05-23 14:54:50 +00:00
|
|
|
}
|