1
0
Fork 0
mirror of synced 2024-06-01 18:39:57 +12:00
appwrite/src/Appwrite/Utopia/Response/Model/BaseList.php
2021-12-15 11:19:29 +01:00

70 lines
1.4 KiB
PHP

<?php
namespace Appwrite\Utopia\Response\Model;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Response\Model;
class BaseList extends Model
{
/**
* @var string
*/
protected $name = '';
/**
* @var string
*/
protected $type = '';
/**
* @param string $name
* @param string $type
* @param string $key
* @param string $model
* @param bool $paging
* @param bool $public
*/
public function __construct(string $name, string $type, string $key, string $model, bool $paging = true, bool $public = true)
{
$this->name = $name;
$this->type = $type;
$this->public = $public;
if ($paging) {
$this->addRule('sum', [
'type' => self::TYPE_INTEGER,
'description' => 'Total number of items available on the server.',
'default' => 0,
'example' => 5,
]);
}
$this->addRule($key, [
'type' => $model,
'description' => 'List of '.$key.'.',
'default' => [],
'array' => true,
]);
}
/**
* Get Name
*
* @return string
*/
public function getName():string
{
return $this->name;
}
/**
* Get Type
*
* @return string
*/
public function getType():string
{
return $this->type;
}
}