| 1: | <?php |
| 2: | |
| 3: | declare(strict_types=1); |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | namespace Nexus\Mcp\Schema\Result; |
| 15: | |
| 16: | use Nexus\Mcp\Schema\Content\BlobResourceContents; |
| 17: | use Nexus\Mcp\Schema\Content\ResourceContents; |
| 18: | use Nexus\Mcp\Schema\Content\TextResourceContents; |
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: | final readonly class ReadResourceResult extends Result implements ServerResult |
| 29: | { |
| 30: | |
| 31: | |
| 32: | |
| 33: | public function __construct( |
| 34: | public array $contents, |
| 35: | ?array $meta = null, |
| 36: | ) { |
| 37: | parent::__construct($meta); |
| 38: | } |
| 39: | |
| 40: | #[\Override] |
| 41: | public function toArray(): array |
| 42: | { |
| 43: | return array_filter([ |
| 44: | '_meta' => $this->meta, |
| 45: | 'contents' => array_map(static fn($item) => $item->toArray(), $this->contents), |
| 46: | ], static fn(mixed $value): bool => null !== $value); |
| 47: | } |
| 48: | } |
| 49: | |