Skip to content

Commit aae7005

Browse files
klapaudiusgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 3ca2c9a commit aae7005

15 files changed

+100
-87
lines changed

src/Server/Request/ResourcesListHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function __construct(ResourceRepository $resourceRepository)
1616

1717
public function isHandle(string $method): bool
1818
{
19-
return in_array($method,['resources/list', 'resources/templates/list']);
19+
return in_array($method, ['resources/list', 'resources/templates/list']);
2020
}
2121

2222
public function execute(string $method, string|int $messageId, ?array $params = null): array

src/Server/Request/ResourcesReadHandler.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public function isHandle(string $method): bool
3939
/**
4040
* Executes a process based on the specified method and message ID, with optional parameters.
4141
*
42-
* @param string $method The method to be executed.
43-
* @param string|int $messageId The identifier of the message associated with the execution.
44-
* @param array|null $params Optional parameters for the execution process.
42+
* @param string $method The method to be executed.
43+
* @param string|int $messageId The identifier of the message associated with the execution.
44+
* @param array|null $params Optional parameters for the execution process.
4545
* @return array An array containing the resource's content information if successful; returns an empty array if no resource is found.
4646
*/
4747
public function execute(string $method, string|int $messageId, ?array $params = null): array
@@ -58,8 +58,8 @@ public function execute(string $method, string|int $messageId, ?array $params =
5858
'uri' => $resource->getUri(),
5959
'mimeType' => $resource->getMimeType(),
6060
$this->getContentType($resource) => $resource->getData(),
61-
]
62-
]
61+
],
62+
],
6363
];
6464
}
6565

src/Services/ResourceService/Examples/HelloWorldResource.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,27 @@ class HelloWorldResource implements ResourceInterface
88
{
99
public function getUri(): string
1010
{
11-
return "file:/hello-world.txt";
11+
return 'file:/hello-world.txt';
1212
}
1313

1414
public function getName(): string
1515
{
16-
return "hello-world.txt";
16+
return 'hello-world.txt';
1717
}
1818

1919
public function getDescription(): string
2020
{
21-
return "The HelloWorld resource.";
21+
return 'The HelloWorld resource.';
2222
}
2323

2424
public function getMimeType(): string
2525
{
26-
return "text/plain";
26+
return 'text/plain';
2727
}
2828

2929
public function getData(): string
3030
{
31-
return "Hello, World!";
31+
return 'Hello, World!';
3232
}
3333

3434
public function getSize(): int

src/Services/ResourceService/Examples/McpDocumentationResource.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ public function __construct(KernelInterface $kernel)
2121

2222
public function getUriTemplate(): string
2323
{
24-
return "file:/docs/{filename}.md";
24+
return 'file:/docs/{filename}.md';
2525
}
2626

2727
public function getName(): string
2828
{
29-
return "documentation.md";
29+
return 'documentation.md';
3030
}
3131

3232
public function getDescription(): string
@@ -44,13 +44,13 @@ public function getDescription(): string
4444

4545
public function getMimeType(): string
4646
{
47-
return "text/plain";
47+
return 'text/plain';
4848
}
4949

5050
/**
5151
* Retrieve a resource by its URI.
5252
*
53-
* @param string $uri The unique identifier of the resource.
53+
* @param string $uri The unique identifier of the resource.
5454
* @return ResourceInterface|null The retrieved resource object, or null if the resource does not exist.
5555
*/
5656
public function getResource(string $uri): ?ResourceInterface
@@ -75,7 +75,7 @@ public function getResource(string $uri): ?ResourceInterface
7575
/**
7676
* Check if the specified resource exists.
7777
*
78-
* @param string $uri The URI of the resource to check.
78+
* @param string $uri The URI of the resource to check.
7979
* @return bool True if the resource exists, false otherwise.
8080
*/
8181
public function resourceExists(string $uri): bool
@@ -88,13 +88,13 @@ public function resourceExists(string $uri): bool
8888
/**
8989
* Extracts the filename from a given URI.
9090
*
91-
* @param string $uri The URI from which to extract the filename.
91+
* @param string $uri The URI from which to extract the filename.
9292
* @return string|null The extracted filename if found, or null otherwise.
9393
*/
9494
private function getFilenameFromUri(string $uri): ?string
9595
{
96-
if (!isset($this->filenames[$uri])) {
97-
if (!preg_match('#^file:/docs/([^/]+)\.md$#', $uri, $matches)) {
96+
if (! isset($this->filenames[$uri])) {
97+
if (! preg_match('#^file:/docs/([^/]+)\.md$#', $uri, $matches)) {
9898
$this->filenames[$uri] = null;
9999
} else {
100100
$this->filenames[$uri] = $matches[1];
@@ -107,12 +107,13 @@ private function getFilenameFromUri(string $uri): ?string
107107
/**
108108
* Guess the MIME type of a file.
109109
*
110-
* @param string $path The path to the file.
110+
* @param string $path The path to the file.
111111
* @return string The guessed MIME type.
112112
*/
113113
protected function guessMimeType(string $path): string
114114
{
115115
$mimeType = mime_content_type($path);
116+
116117
return $mimeType ?: 'application/octet-stream';
117118
}
118119
}

src/Services/ResourceService/Resource.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ class Resource implements ResourceInterface
4040
/**
4141
* Constructor.
4242
*
43-
* @param string $uri The URI of the resource.
44-
* @param string $name The name of the resource.
45-
* @param string $description The description of the resource.
46-
* @param string $mimeType The MIME type of the resource.
47-
* @param string $data The data of the resource.
43+
* @param string $uri The URI of the resource.
44+
* @param string $name The name of the resource.
45+
* @param string $description The description of the resource.
46+
* @param string $mimeType The MIME type of the resource.
47+
* @param string $data The data of the resource.
4848
*/
4949
public function __construct(string $uri, string $name, string $description, string $mimeType, string $data)
5050
{
@@ -107,49 +107,49 @@ public function getSize(): int
107107
/**
108108
* Set the name of the resource.
109109
*
110-
* @param string $name The new name of the resource.
111-
* @return self
110+
* @param string $name The new name of the resource.
112111
*/
113112
public function setName(string $name): self
114113
{
115114
$this->name = $name;
115+
116116
return $this;
117117
}
118118

119119
/**
120120
* Set the description of the resource.
121121
*
122-
* @param string $description The new description of the resource.
123-
* @return self
122+
* @param string $description The new description of the resource.
124123
*/
125124
public function setDescription(string $description): self
126125
{
127126
$this->description = $description;
127+
128128
return $this;
129129
}
130130

131131
/**
132132
* Set the MIME type of the resource.
133133
*
134-
* @param string $mimeType The new MIME type of the resource.
135-
* @return self
134+
* @param string $mimeType The new MIME type of the resource.
136135
*/
137136
public function setMimeType(string $mimeType): self
138137
{
139138
$this->mimeType = $mimeType;
139+
140140
return $this;
141141
}
142142

143143
/**
144144
* Set the data of the resource.
145145
*
146-
* @param string $data The new data of the resource.
147-
* @return self
146+
* @param string $data The new data of the resource.
148147
*/
149148
public function setData(string $data): self
150149
{
151150
$this->data = $data;
152151
$this->size = strlen($data);
152+
153153
return $this;
154154
}
155155
}

src/Services/ResourceService/ResourceInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace KLP\KlpMcpServer\Services\ResourceService;
44

5-
use KLP\KlpMcpServer\Services\ToolService\Annotation\ToolAnnotation;
6-
75
interface ResourceInterface extends ResourceDescriptorInterface
86
{
97
/**

src/Services/ResourceService/ResourceRepository.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public function getResource(string $uri): ?ResourceInterface
161161
$resource = $resourceTemplate->getResource($uri);
162162
if ($resource) {
163163
$this->resources[$uri] = $resource;
164+
164165
return $resource;
165166
}
166167
}
@@ -183,7 +184,7 @@ public function getResourceSchemas(): array
183184
'uri' => $resource->getUri(),
184185
'name' => $resource->getName(),
185186
'description' => $resource->getDescription(),
186-
'mimeType' => $resource->getMimeType()
187+
'mimeType' => $resource->getMimeType(),
187188
];
188189
}
189190

@@ -204,7 +205,7 @@ public function getResourceTemplateSchemas(): array
204205
'uriTemplate' => $resourceTemplate->getUriTemplate(),
205206
'name' => $resourceTemplate->getName(),
206207
'description' => $resourceTemplate->getDescription(),
207-
'mimeType' => $resourceTemplate->getMimeType()
208+
'mimeType' => $resourceTemplate->getMimeType(),
208209
];
209210
}
210211

src/Services/ResourceService/ResourceTemplateInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ public function getUriTemplate(): string;
1818
/**
1919
* Get a resource by its URI.
2020
*
21-
* @param string $uri The URI of the resource to retrieve.
21+
* @param string $uri The URI of the resource to retrieve.
2222
* @return ResourceInterface|null The resource if found, null otherwise.
2323
*/
2424
public function getResource(string $uri): ?ResourceInterface;
2525

2626
/**
2727
* Check if a resource exists.
2828
*
29-
* @param string $uri The URI of the resource to check.
29+
* @param string $uri The URI of the resource to check.
3030
* @return bool True if the resource exists, false otherwise.
3131
*/
3232
public function resourceExists(string $uri): bool;

tests/DependencyInjection/CompilerPass/ResourcesDefinitionCompilerPassTest.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#[Small]
1212
class ResourcesDefinitionCompilerPassTest extends TestCase
1313
{
14-
public function testProcessRegistersResourcesAsServices()
14+
public function test_process_registers_resources_as_services()
1515
{
1616
eval('namespace App\Resource; class ResourceA {}');
1717
eval('namespace App\Resource; class ResourceB {}');
@@ -21,12 +21,13 @@ public function testProcessRegistersResourcesAsServices()
2121

2222
$invocations = [
2323
'klp_mcp_server.resources',
24-
'klp_mcp_server.resources_templates'
24+
'klp_mcp_server.resources_templates',
2525
];
2626
$container->expects($matcher = $this->exactly(2))
2727
->method('getParameter')
2828
->with($this->callback(function ($argument) use ($invocations, $matcher) {
2929
$this->assertEquals($argument, $invocations[$matcher->numberOfInvocations() - 1]);
30+
3031
return true;
3132
}))
3233
->willReturnOnConsecutiveCalls(
@@ -42,6 +43,7 @@ public function testProcessRegistersResourcesAsServices()
4243
->method('has')
4344
->with($this->callback(function ($argument) use ($invocations, $matcher) {
4445
$this->assertEquals($argument, $invocations[$matcher->numberOfInvocations() - 1]);
46+
4547
return true;
4648
}))
4749
->willReturnOnConsecutiveCalls(false, false);
@@ -50,26 +52,28 @@ public function testProcessRegistersResourcesAsServices()
5052
->method('setDefinition')
5153
->with($this->callback(function ($argument) use ($invocations, $matcher) {
5254
$this->assertEquals($argument, $invocations[$matcher->numberOfInvocations() - 1]);
55+
5356
return true;
5457
}));
5558

56-
$pass = new ResourcesDefinitionCompilerPass();
59+
$pass = new ResourcesDefinitionCompilerPass;
5760
$pass->process($container);
5861
}
5962

60-
public function testProcessDoesNotRegisterAlreadyDefinedResources()
63+
public function test_process_does_not_register_already_defined_resources()
6164
{
6265
$container = $this->createMock(ContainerBuilder::class);
6366
$resources = ['App\Resource\ExistingResource'];
6467

6568
$invocations = [
6669
'klp_mcp_server.resources',
67-
'klp_mcp_server.resources_templates'
70+
'klp_mcp_server.resources_templates',
6871
];
6972
$container->expects($matcher = $this->exactly(count($invocations)))
7073
->method('getParameter')
7174
->with($this->callback(function ($argument) use ($invocations, $matcher) {
7275
$this->assertEquals($argument, $invocations[$matcher->numberOfInvocations() - 1]);
76+
7377
return true;
7478
}))
7579
->willReturnOnConsecutiveCalls(
@@ -85,24 +89,25 @@ public function testProcessDoesNotRegisterAlreadyDefinedResources()
8589
$container->expects($this->never())
8690
->method('setDefinition');
8791

88-
$pass = new ResourcesDefinitionCompilerPass();
92+
$pass = new ResourcesDefinitionCompilerPass;
8993
$pass->process($container);
9094
}
9195

92-
public function testProcessAddsMethodCallToServer()
96+
public function test_process_adds_method_call_to_server()
9397
{
9498
$container = $this->createMock(ContainerBuilder::class);
9599
$serverDefinition = $this->createMock(Definition::class);
96100
$resourceRepositoryDefinition = $this->createMock(Definition::class);
97101

98102
$invocations = [
99103
'klp_mcp_server.resources',
100-
'klp_mcp_server.resources_templates'
104+
'klp_mcp_server.resources_templates',
101105
];
102106
$container->expects($matcher = $this->exactly(count($invocations)))
103107
->method('getParameter')
104108
->with($this->callback(function ($argument) use ($invocations, $matcher) {
105109
$this->assertEquals($argument, $invocations[$matcher->numberOfInvocations() - 1]);
110+
106111
return true;
107112
}))
108113
->willReturn([]);
@@ -115,6 +120,7 @@ public function testProcessAddsMethodCallToServer()
115120
->method('getDefinition')
116121
->with($this->callback(function ($argument) use ($invocations, $matcher) {
117122
$this->assertEquals($argument, $invocations[$matcher->numberOfInvocations() - 1]);
123+
118124
return true;
119125
}))
120126
->willReturnOnConsecutiveCalls(
@@ -126,7 +132,7 @@ public function testProcessAddsMethodCallToServer()
126132
->method('addMethodCall')
127133
->with('registerResourceRepository', [$resourceRepositoryDefinition]);
128134

129-
$pass = new ResourcesDefinitionCompilerPass();
135+
$pass = new ResourcesDefinitionCompilerPass;
130136
$pass->process($container);
131137
}
132138
}

tests/DependencyInjection/KlpMcpServerExtensionTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ protected function setUp(): void
2525
$this->container = new ContainerBuilder;
2626
}
2727

28-
2928
/**
3029
* Tests that all parameters are correctly set when loading a valid configuration
3130
*/

0 commit comments

Comments
 (0)