mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-23 20:00:27 +08:00
42 lines
1.0 KiB
PHP
42 lines
1.0 KiB
PHP
<?php
|
|
/**
|
|
* @copyright Copyright (c) 2021 深圳市酷瓜软件有限公司
|
|
* @license https://opensource.org/licenses/GPL-2.0
|
|
* @link https://www.koogua.com
|
|
*/
|
|
|
|
namespace App\Validators;
|
|
|
|
use App\Exceptions\BadRequest as BadRequestException;
|
|
use App\Library\Validators\Common as CommonValidator;
|
|
|
|
class ChapterOffline extends Validator
|
|
{
|
|
|
|
public function checkStartTime($startTime)
|
|
{
|
|
if (!CommonValidator::date($startTime, 'Y-m-d H:i:s')) {
|
|
throw new BadRequestException('chapter_offline.invalid_start_time');
|
|
}
|
|
|
|
return strtotime($startTime);
|
|
}
|
|
|
|
public function checkEndTime($endTime)
|
|
{
|
|
if (!CommonValidator::date($endTime, 'Y-m-d H:i:s')) {
|
|
throw new BadRequestException('chapter_offline.invalid_end_time');
|
|
}
|
|
|
|
return strtotime($endTime);
|
|
}
|
|
|
|
public function checkTimeRange($startTime, $endTime)
|
|
{
|
|
if ($startTime >= $endTime) {
|
|
throw new BadRequestException('chapter_offline.start_gt_end');
|
|
}
|
|
}
|
|
|
|
}
|