| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Core\Schema\Result; |
| 15: | |
| 16: | use Nexus\Assert\Assert; |
| 17: | use Nexus\Mcp\Core\Schema\MetaObject; |
| 18: | use Nexus\Mcp\Core\Schema\Result; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | final readonly class EmptyResult extends Result implements ClientResult, ServerResult |
| 27: | { |
| 28: | public function __construct(MetaObject $meta = new MetaObject()) |
| 29: | { |
| 30: | parent::__construct($meta); |
| 31: | } |
| 32: | |
| 33: | #[\Override] |
| 34: | public static function fromArray(array $data): static |
| 35: | { |
| 36: | $meta = new MetaObject(); |
| 37: | |
| 38: | if (\array_key_exists('_meta', $data)) { |
| 39: | Assert::that($data['_meta']) |
| 40: | ->isArray('"result._meta" must be an object, {type} given.') |
| 41: | ->isMap('"result._meta" must be a string-keyed object.') |
| 42: | ; |
| 43: | $meta = MetaObject::fromArray($data['_meta']); |
| 44: | } |
| 45: | |
| 46: | return new self($meta); |
| 47: | } |
| 48: | } |
| 49: | |