You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

46 lines
1.2 KiB

<?php
declare(strict_types=1);
/**
* ScoreStrategyInterface.php
* Created by PhpStorm.
* Date: 2026/10/17
* Time: 09:40
* Author: qian.guo
* E-mail: yiyezhiqiutel@gmail.com
*/
namespace app\service\score;
/**
* 评分策略接口
* 实现必须满足三条:
* 1. 纯计算:相同 ScoreContext 必得相同 ScoreResult,不读写外部状态、不访问数据库/网络/缓存
* 这是做 A/B 对比与单测的前提,与选型无关,换任何存储都一样
* 2. 不取数:需要的数据都在 ScoreContext 里,自己不去查
* 3. 输出同构:返回的 ScoreResult 结构必须与其他策略完全一致
*/
interface ScoreStrategyInterface
{
/**
* 获取策略标识
* getName
* @return string 与 config/score.php 的注册键一致,用于落库
*/
public function getName();
/**
* 获取策略版本
* getVersion
* @return string 算法语义变更时必须递增,否则历史结果无法按口径分组
*/
public function getVersion();
/**
* 执行评分
* score
* @param ScoreContext $context 评分输入
* @return ScoreResult
*/
public function score(ScoreContext $context);
}