40 lines
993 B
PHP
40 lines
993 B
PHP
<?php
|
|
|
|
namespace App\Services\AiEditing\Safety;
|
|
|
|
class AiSafetyDecision
|
|
{
|
|
/**
|
|
* @param array<int, string> $reasonCodes
|
|
*/
|
|
public function __construct(
|
|
public readonly bool $blocked,
|
|
public readonly string $state,
|
|
public readonly array $reasonCodes = [],
|
|
public readonly ?string $failureCode = null,
|
|
public readonly ?string $failureMessage = null,
|
|
) {}
|
|
|
|
public static function passed(): self
|
|
{
|
|
return new self(
|
|
blocked: false,
|
|
state: 'passed',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param array<int, string> $reasonCodes
|
|
*/
|
|
public static function blocked(array $reasonCodes, string $failureCode, string $failureMessage): self
|
|
{
|
|
return new self(
|
|
blocked: true,
|
|
state: 'blocked',
|
|
reasonCodes: array_values(array_unique($reasonCodes)),
|
|
failureCode: $failureCode,
|
|
failureMessage: $failureMessage,
|
|
);
|
|
}
|
|
}
|