f2ff4ae123
- 将 FLOW_USE_CUSTOM_PROCESS 从 true 改为 false,禁用自定义流程 - 在 BlockTest 测试用例中改用 setBlockMode 方法设置阻断模式 - 设置统一的错误处理,将错误转为异常抛出 - 重命名 BlockTest 测试文件路径,优化测试组织结构 - 更新 IDE php include paths,调整依赖包引用顺序 - 删除无用的 tests/flow/Test.php 测试文件 - 微调 start.php、webman、windows.php 配置或代码模块
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace app\flow\context\bean;
|
|
|
|
use app\flow\enum\VoiceMessage;
|
|
|
|
/**
|
|
* 节点能否处理的判断结果
|
|
* 封装 canHandle 方法的返回值(不可变)
|
|
*/
|
|
readonly class CanHandleResult
|
|
{
|
|
public function __construct(
|
|
/** 是否能处理 */
|
|
public bool $canHandle,
|
|
/** 如果不能处理,期望的下一步提示 */
|
|
public VoiceMessage $expectedNextStep = VoiceMessage::NONE,
|
|
) {}
|
|
|
|
/**
|
|
* 创建可以处理的结果
|
|
*/
|
|
public static function canHandle(): self
|
|
{
|
|
return new self(canHandle: true);
|
|
}
|
|
|
|
/**
|
|
* 创建不能处理的结果
|
|
*/
|
|
public static function cannotHandle(?VoiceMessage $expectedNextStep = null): self
|
|
{
|
|
return new self(
|
|
canHandle: false,
|
|
expectedNextStep: $expectedNextStep ?? VoiceMessage::NONE
|
|
);
|
|
}
|
|
|
|
/**
|
|
* 是否能处理
|
|
*/
|
|
public function isCanHandle(): bool
|
|
{
|
|
return $this->canHandle;
|
|
}
|
|
|
|
/**
|
|
* 是否有期望下一步提示
|
|
*/
|
|
public function hasExpectedNextStep(): bool
|
|
{
|
|
return $this->expectedNextStep !== VoiceMessage::NONE;
|
|
}
|
|
}
|