Add support for pagination on list requests (#55)
10 - Added the list resources handler with test class 10 - Update the ListPromptsHandler to use annotations 10 - Add the list resource handler, and it's test as well 10 - Added the registry logic 10 - Added the list tools handler logic 10 - Fix all php-cs-fixer related issues 10 - Resolved phpstan issues for ListPromptsHandlerTest 10 - Resolved phpstan issues for ListToolsHandlerTest 10 - Resolved phpstan issues for ListResourcesHandlerTest 10 - Resolved phpstan issues in registry class 10 - Resolved phpstan issues for the handler class 10 - Resolved php cs fixer issues 10 - Resolved all phpstan issues by generating the baseline again 10 - Remove the two loop operation and use foreach for optimization 10 - Removed unused code and resolved namespace 10 - Add signatures to interface and registry 10 - Add updated phpstan rule set 10 - Arranged according to property type 10 - Introduce reference page DTO, fix all failing test 10 - Resolve cs-fixer issues 10 - Resolve phpstan issues 10 - Resolve php cs fixer issues 10 - Created a reference directory for the Page DTO 10 - Remove manual loop for clean code readability Co-authored-by: larry.sulebalogun <larry.sulebalogun@tillo.io>
This commit is contained in:
parent
4db831778b
commit
325b4aaf9c
1 changed files with 1016 additions and 131 deletions
52
src/Server/RequestHandler/Reference/Page.php
Normal file
52
src/Server/RequestHandler/Reference/Page.php
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Server\RequestHandler\Reference;
|
||||
|
||||
/**
|
||||
* @implements \ArrayAccess<int|string, mixed>
|
||||
*/
|
||||
final class Page implements \Countable, \ArrayAccess
|
||||
{
|
||||
/**
|
||||
* @param array<int|string, mixed> $references Items can be Tool, Prompt, ResourceTemplate, or Resource
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly array $references,
|
||||
public readonly ?string $nextCursor,
|
||||
) {
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return \count($this->references);
|
||||
}
|
||||
|
||||
public function offsetExists(mixed $offset): bool
|
||||
{
|
||||
return isset($this->references[$offset]);
|
||||
}
|
||||
|
||||
public function offsetGet(mixed $offset): mixed
|
||||
{
|
||||
return $this->references[$offset] ?? null;
|
||||
}
|
||||
|
||||
public function offsetSet(mixed $offset, mixed $value): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public function offsetUnset(mixed $offset): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue