Files
yii2/tests/framework/models/JsonModel.php
2023-10-23 11:26:59 -03:00

52 lines
882 B
PHP

<?php
/**
* @link https://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license https://www.yiiframework.com/license/
*/
namespace yiiunit\framework\models;
use yii\base\DynamicModel;
/**
* JSON serializable model for tests.
*
* {@inheritdoc}
*/
class JsonModel extends DynamicModel implements \JsonSerializable
{
/**
* @var array
*/
public $data = ['json' => 'serializable'];
/**
* @return array
*/
#[\ReturnTypeWillChange]
public function jsonSerialize()
{
return $this->data;
}
/**
* @inheritdoc
*/
public function init(): void
{
$this->defineAttribute('name');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
['name', 'required'],
['name', 'string', 'max' => 100]
];
}
}