portal.mkgtu.ru/common/modules/student/components/block/models/CreateIndividualResult.php

32 lines
703 B
PHP
Raw Normal View History

2024-03-28 09:51:45 +03:00
<?php
namespace common\modules\student\components\block\models;
use common\modules\student\models\Error;
use common\modules\student\models\ResultType;
class CreateIndividualResult
{
public $result;
public $error = [];
public static function fromRaw($data): CreateIndividualResult
{
$instance = new CreateIndividualResult();
$instance->result = $data->Result ?? ResultType::FAIL;
if (isset($data->Error)) {
$errors = is_array($data->Error) ? $data->Error : [$data->Error];
foreach ($errors as $error) {
$instance->error[] = Error::fromRaw($error);
}
}
return $instance;
}
}