Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

Commit 7ddaaa0

Browse files
committed
Add some more method documentation
1 parent 3d26bc4 commit 7ddaaa0

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/Contract/ApiMethodInterface.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
interface ApiMethodInterface
1212
{
1313
/**
14-
* @return array<mixed, mixed>
14+
* This method contains the business logic of the api method
15+
*
16+
* @param stdClass $parameter The method parameter as described in the schema
17+
*
18+
* @return array<mixed, mixed> The api method response
1519
*
1620
* @throws ApiMethodException
1721
*/
@@ -20,5 +24,8 @@ public function handle(
2024
stdClass $parameter
2125
): array;
2226

27+
/**
28+
* Return the absolute path to the corresponding json schema
29+
*/
2330
public function getSchemaFile(): string;
2431
}

src/Contract/MethodProviderInterface.php

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
namespace Usox\JsonSchemaApi\Contract;
44

5+
/**
6+
* A method provider should perform a lookup an api method by its name.
7+
* If api versions are used, the version number gets appended to the method name.
8+
* e.g. someNamespace.someMethod, someNamespace.someMethod.1
9+
*
10+
* If the method name does not exist, lookup is expected to return null.
11+
*/
512
interface MethodProviderInterface
613
{
714
public function lookup(

src/Endpoint.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public function __construct(
5959
$this->logger = $logger;
6060
}
6161

62+
/**
63+
* Try to execute the api handler and build the response
64+
*/
6265
public function serve(
6366
ServerRequestInterface $request,
6467
ResponseInterface $response
@@ -130,12 +133,17 @@ private function log(
130133
);
131134
}
132135
}
133-
136+
137+
/**
138+
* Builds the endpoint.
139+
* The StreamFactory can be omitted, the endpoint will search
140+
* for any existing PSR17 implementations
141+
*/
134142
public static function factory(
135143
MethodProviderInterface $methodProvider,
136144
?StreamFactoryInterface $streamFactory = null,
137145
?LoggerInterface $logger = null
138-
): Endpoint {
146+
): EndpointInterface {
139147
$schemaValidator = new Validator();
140148
$schemaLoader = new SchemaLoader();
141149

0 commit comments

Comments
 (0)