ai-chore(config): 调整流程配置及改进测试代码
- 将 FLOW_USE_CUSTOM_PROCESS 从 true 改为 false,禁用自定义流程 - 在 BlockTest 测试用例中改用 setBlockMode 方法设置阻断模式 - 设置统一的错误处理,将错误转为异常抛出 - 重命名 BlockTest 测试文件路径,优化测试组织结构 - 更新 IDE php include paths,调整依赖包引用顺序 - 删除无用的 tests/flow/Test.php 测试文件 - 微调 start.php、webman、windows.php 配置或代码模块
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace app\flow\context\bean;
|
||||
|
||||
/**
|
||||
* 晨洗状态值对象
|
||||
* 封装内镜的晨洗相关状态信息,不可变对象
|
||||
*/
|
||||
readonly class MorningWashStatus
|
||||
{
|
||||
public function __construct(
|
||||
/** 是否需要晨洗 */
|
||||
public bool $needMorningWash = false,
|
||||
/** 是否已完成晨洗 */
|
||||
public bool $morningWashed = false,
|
||||
/** 晨洗开始时间(如 06:00:00) */
|
||||
public string $startTime = '00:00:00',
|
||||
/** 今天洗消记录数 */
|
||||
public int $todayWashRecords = 0,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* 创建默认的晨洗状态(不需要晨洗)
|
||||
*/
|
||||
public static function notRequired(): self
|
||||
{
|
||||
return new self(needMorningWash: false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建需要晨洗的状态
|
||||
*/
|
||||
public static function required(string $startTime = '06:00:00', int $todayWashRecords = 0): self
|
||||
{
|
||||
return new self(
|
||||
needMorningWash: true,
|
||||
morningWashed: false,
|
||||
startTime: $startTime,
|
||||
todayWashRecords: $todayWashRecords
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建已完成晨洗的状态
|
||||
*/
|
||||
public static function completed(string $startTime = '06:00:00'): self
|
||||
{
|
||||
return new self(
|
||||
needMorningWash: true,
|
||||
morningWashed: true,
|
||||
startTime: $startTime
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要进行晨洗(需要且未完成)
|
||||
*/
|
||||
public function shouldDoMorningWash(): bool
|
||||
{
|
||||
return $this->needMorningWash && !$this->morningWashed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断晨洗是否已完成
|
||||
*/
|
||||
public function isCompleted(): bool
|
||||
{
|
||||
return $this->morningWashed;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断今天是否有洗消记录
|
||||
*/
|
||||
public function hasWashRecordsToday(): bool
|
||||
{
|
||||
return $this->todayWashRecords > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为数组
|
||||
*/
|
||||
public function toArray(): array
|
||||
{
|
||||
return [
|
||||
'needMorningWash' => $this->needMorningWash,
|
||||
'morningWashed' => $this->morningWashed,
|
||||
'startTime' => $this->startTime,
|
||||
'todayWashRecords' => $this->todayWashRecords,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user