Skip to content

Commit 0030617

Browse files
binarykgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 8b51af8 commit 0030617

File tree

15 files changed

+155
-161
lines changed

15 files changed

+155
-161
lines changed

src/Fields/Field.php

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class Field extends OrganicField implements JsonSerializable
131131
public $label;
132132

133133
public $toolInputSchemaCallback = null;
134+
134135
/**
135136
* Create a new field.
136137
*
@@ -753,8 +754,6 @@ public function image(): Image
753754

754755
/**
755756
* Guess the field type based on validation rules, field class, and attribute patterns.
756-
*
757-
* @return string
758757
*/
759758
public function guessFieldType(): string
760759
{
@@ -787,7 +786,7 @@ protected function guessTypeFromFieldClass(): ?string
787786
{
788787
$className = class_basename(static::class);
789788

790-
return match($className) {
789+
return match ($className) {
791790
'Boolean', 'BooleanField' => 'boolean',
792791
'Number', 'Integer', 'Decimal', 'Float' => 'number',
793792
'Email' => 'string',
@@ -817,6 +816,7 @@ protected function guessTypeFromValidationRules(): ?string
817816
if (is_object($rule)) {
818817
return get_class($rule);
819818
}
819+
820820
return (string) $rule;
821821
})->toArray();
822822

@@ -855,7 +855,7 @@ protected function guessTypeFromAttributeName(): ?string
855855
{
856856
$attribute = $this->attribute;
857857

858-
if (!is_string($attribute)) {
858+
if (! is_string($attribute)) {
859859
return null;
860860
}
861861

@@ -917,7 +917,6 @@ protected function hasAnyRule(array $ruleStrings, array $rulesToCheck): bool
917917
/**
918918
* Set a custom callback for defining the tool schema.
919919
*
920-
* @param callable|Closure $callback
921920
* @return $this
922921
*/
923922
public function toolSchema(callable|Closure $callback): self
@@ -935,6 +934,7 @@ public function resolveToolSchema(ToolInputSchema $schema, Repository $repositor
935934
// Check if there's a custom callback defined
936935
if (is_callable($this->toolInputSchemaCallback)) {
937936
call_user_func($this->toolInputSchemaCallback, $schema, $repository, $this);
937+
938938
return $this;
939939
}
940940

@@ -947,7 +947,7 @@ public function resolveToolSchema(ToolInputSchema $schema, Repository $repositor
947947
$fieldType = $this->guessFieldType();
948948

949949
// Add the field to schema based on its type
950-
$schemaField = match($fieldType) {
950+
$schemaField = match ($fieldType) {
951951
'boolean' => $schema->boolean($attribute),
952952
'number' => $schema->number($attribute),
953953
'array' => $schema->string($attribute), // Arrays are typically sent as JSON strings
@@ -978,27 +978,27 @@ protected function generateFieldDescription(Repository $repository): string
978978

979979
// Add validation rules information
980980
$rules = $this->getStoringRules();
981-
if (!empty($rules)) {
981+
if (! empty($rules)) {
982982
$ruleDescriptions = $this->formatValidationRules($rules);
983-
if (!empty($ruleDescriptions)) {
984-
$description .= ". Validation: " . implode(', ', $ruleDescriptions);
983+
if (! empty($ruleDescriptions)) {
984+
$description .= '. Validation: '.implode(', ', $ruleDescriptions);
985985
}
986986
}
987987

988988
// Add relationship information for relationship fields
989989
if ($this->isRelationshipField()) {
990-
$description .= ". This is a relationship field";
990+
$description .= '. This is a relationship field';
991991
}
992992

993993
// Add file information for file fields
994994
if ($this instanceof File) {
995-
$description .= ". Upload a file";
995+
$description .= '. Upload a file';
996996
}
997997

998998
// Add examples based on field type and name
999999
$examples = $this->generateFieldExamples();
1000-
if (!empty($examples)) {
1001-
$description .= ". Examples: " . implode(', ', $examples);
1000+
if (! empty($examples)) {
1001+
$description .= '. Examples: '.implode(', ', $examples);
10021002
}
10031003

10041004
return $description;
@@ -1010,8 +1010,9 @@ protected function generateFieldDescription(Repository $repository): string
10101010
protected function isRequired(): bool
10111011
{
10121012
$rules = $this->getStoringRules();
1013+
10131014
return in_array('required', $rules) ||
1014-
collect($rules)->contains(function($rule) {
1015+
collect($rules)->contains(function ($rule) {
10151016
return is_string($rule) && str_starts_with($rule, 'required');
10161017
});
10171018
}
@@ -1036,18 +1037,18 @@ protected function formatValidationRules(array $rules): array
10361037

10371038
foreach ($rules as $rule) {
10381039
if (is_string($rule)) {
1039-
$formatted[] = match(true) {
1040+
$formatted[] = match (true) {
10401041
$rule === 'required' => 'required',
1041-
str_starts_with($rule, 'min:') => 'minimum ' . substr($rule, 4) . ' characters',
1042-
str_starts_with($rule, 'max:') => 'maximum ' . substr($rule, 4) . ' characters',
1043-
str_starts_with($rule, 'between:') => 'between ' . str_replace(',', ' and ', substr($rule, 8)),
1042+
str_starts_with($rule, 'min:') => 'minimum '.substr($rule, 4).' characters',
1043+
str_starts_with($rule, 'max:') => 'maximum '.substr($rule, 4).' characters',
1044+
str_starts_with($rule, 'between:') => 'between '.str_replace(',', ' and ', substr($rule, 8)),
10441045
$rule === 'email' => 'valid email format',
10451046
$rule === 'url' => 'valid URL format',
10461047
$rule === 'numeric' => 'numeric value',
10471048
$rule === 'integer' => 'integer value',
10481049
$rule === 'boolean' => 'boolean value (true/false)',
10491050
$rule === 'array' => 'array format',
1050-
str_starts_with($rule, 'in:') => 'allowed values: ' . str_replace(',', ', ', substr($rule, 3)),
1051+
str_starts_with($rule, 'in:') => 'allowed values: '.str_replace(',', ', ', substr($rule, 3)),
10511052
default => $rule
10521053
};
10531054
}
@@ -1064,7 +1065,7 @@ protected function generateFieldExamples(): array
10641065
$attribute = strtolower($this->attribute);
10651066
$fieldType = $this->guessFieldType();
10661067

1067-
return match($fieldType) {
1068+
return match ($fieldType) {
10681069
'boolean' => ['true', 'false'],
10691070
'number' => $this->getNumberExamples($attribute),
10701071
'array' => ['["item1", "item2"]', '{"key": "value"}'],

src/Http/Requests/Concerns/DetermineRequestType.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function isIndexRequest(): bool
2424
if ($this instanceof McpRequest) {
2525
return $this->isIndexRequest();
2626
}
27-
27+
2828
return $this instanceof RepositoryIndexRequest;
2929
}
3030

@@ -38,7 +38,7 @@ public function isShowRequest(): bool
3838
if ($this instanceof McpRequest) {
3939
return $this->isShowRequest();
4040
}
41-
41+
4242
return $this instanceof RepositoryShowRequest;
4343
}
4444

@@ -47,7 +47,7 @@ public function isUpdateRequest(): bool
4747
if ($this instanceof McpRequest) {
4848
return $this->isUpdateRequest();
4949
}
50-
50+
5151
return $this instanceof RepositoryUpdateRequest;
5252
}
5353

@@ -56,7 +56,7 @@ public function isStoreRequest(): bool
5656
if ($this instanceof McpRequest) {
5757
return $this->isStoreRequest();
5858
}
59-
59+
6060
return $this instanceof RepositoryStoreRequest;
6161
}
6262

@@ -65,7 +65,7 @@ public function isDestroyRequest(): bool
6565
if ($this instanceof McpRequest) {
6666
return $this->isDestroyRequest();
6767
}
68-
68+
6969
return $this instanceof RepositoryDestroyRequest;
7070
}
7171

@@ -74,7 +74,7 @@ public function isStoreBulkRequest(): bool
7474
if ($this instanceof McpRequest) {
7575
return $this->isStoreBulkRequest();
7676
}
77-
77+
7878
return $this instanceof RepositoryStoreBulkRequest;
7979
}
8080

@@ -83,7 +83,7 @@ public function isUpdateBulkRequest(): bool
8383
if ($this instanceof McpRequest) {
8484
return $this->isUpdateBulkRequest();
8585
}
86-
86+
8787
return $this instanceof RepositoryUpdateBulkRequest;
8888
}
8989

@@ -92,7 +92,7 @@ public function isActionRequest(): bool
9292
if ($this instanceof McpRequest) {
9393
return $this->isActionRequest();
9494
}
95-
95+
9696
return $this instanceof ActionRequest;
9797
}
9898

@@ -101,7 +101,7 @@ public function isGetterRequest(): bool
101101
if ($this instanceof McpRequest) {
102102
return $this->isGetterRequest();
103103
}
104-
104+
105105
return $this instanceof GetterRequest;
106106
}
107107
}

src/MCP/Concerns/McpTools.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function showTool(array $arguments, McpRequest $request): array
5353
$request->merge($arguments);
5454
$this->sanitizeToolRequest($request, $arguments);
5555

56-
5756
// Build the query following the same pattern as RepositoryShowController
5857
$query = static::query($request);
5958

src/MCP/Requests/McpRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public function isUpdateRequest(): bool
3737
public function isDestroyRequest(): bool
3838
{
3939
$toolName = $this->getToolName();
40+
4041
return str_contains($toolName, '-delete-tool') || str_contains($toolName, '-destroy-tool');
4142
}
4243

src/MCP/RestifyServer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
use Binaryk\LaravelRestify\MCP\Concerns\McpTools;
88
use Binaryk\LaravelRestify\MCP\Resources\ApplicationInfo;
9+
use Binaryk\LaravelRestify\MCP\Tools\Operations\DeleteTool;
910
use Binaryk\LaravelRestify\MCP\Tools\Operations\IndexTool;
1011
use Binaryk\LaravelRestify\MCP\Tools\Operations\ShowTool;
1112
use Binaryk\LaravelRestify\MCP\Tools\Operations\StoreTool;
1213
use Binaryk\LaravelRestify\MCP\Tools\Operations\UpdateTool;
13-
use Binaryk\LaravelRestify\MCP\Tools\Operations\DeleteTool;
1414
use Binaryk\LaravelRestify\Restify;
1515
use Laravel\Mcp\Server;
1616

src/MCP/Tools/Operations/DeleteTool.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
namespace Binaryk\LaravelRestify\MCP\Tools\Operations;
44

5-
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
65
use Binaryk\LaravelRestify\Repositories\Repository;
76
use Generator;
8-
use Illuminate\Support\Str;
97
use Laravel\Mcp\Server\Tool;
108
use Laravel\Mcp\Server\Tools\ToolInputSchema;
119
use Laravel\Mcp\Server\Tools\ToolResult;
@@ -22,30 +20,30 @@ public function __construct(string $repositoryClass)
2220
public function name(): string
2321
{
2422
$uriKey = $this->repository->uriKey();
25-
23+
2624
return "{$uriKey}-delete-tool";
2725
}
2826

2927
public function description(): string
3028
{
3129
$uriKey = $this->repository->uriKey();
3230
$modelName = class_basename($this->repository::$model);
33-
31+
3432
return "Delete an existing {$modelName} record by ID from the {$uriKey} repository.";
3533
}
3634

3735
public function schema(ToolInputSchema $schema): ToolInputSchema
3836
{
3937
$repositoryClass = get_class($this->repository);
4038
$repositoryClass::destroyToolSchema($schema);
41-
39+
4240
return $schema;
4341
}
4442

4543
public function handle(array $arguments): ToolResult|Generator
4644
{
4745
$result = $this->repository->deleteTool($arguments);
48-
46+
4947
return ToolResult::json($result);
5048
}
51-
}
49+
}

src/MCP/Tools/Operations/IndexTool.php

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

33
namespace Binaryk\LaravelRestify\MCP\Tools\Operations;
44

5-
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
65
use Binaryk\LaravelRestify\MCP\Requests\McpRequest;
76
use Binaryk\LaravelRestify\Repositories\Repository;
87
use Generator;
9-
use Illuminate\Support\Str;
108
use Laravel\Mcp\Server\Tool;
119
use Laravel\Mcp\Server\Tools\ToolInputSchema;
1210
use Laravel\Mcp\Server\Tools\ToolResult;

src/MCP/Tools/Operations/ShowTool.php

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

33
namespace Binaryk\LaravelRestify\MCP\Tools\Operations;
44

5-
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
65
use Binaryk\LaravelRestify\MCP\Requests\McpRequest;
76
use Binaryk\LaravelRestify\Repositories\Repository;
87
use Generator;
9-
use Illuminate\Support\Str;
108
use Laravel\Mcp\Server\Tool;
119
use Laravel\Mcp\Server\Tools\ToolInputSchema;
1210
use Laravel\Mcp\Server\Tools\ToolResult;

src/MCP/Tools/Operations/StoreTool.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22

33
namespace Binaryk\LaravelRestify\MCP\Tools\Operations;
44

5-
use Binaryk\LaravelRestify\Http\Requests\RestifyRequest;
65
use Binaryk\LaravelRestify\Repositories\Repository;
76
use Generator;
8-
use Illuminate\Support\Str;
97
use Laravel\Mcp\Server\Tool;
108
use Laravel\Mcp\Server\Tools\ToolInputSchema;
119
use Laravel\Mcp\Server\Tools\ToolResult;
@@ -22,30 +20,30 @@ public function __construct(string $repositoryClass)
2220
public function name(): string
2321
{
2422
$uriKey = $this->repository->uriKey();
25-
23+
2624
return "{$uriKey}-store-tool";
2725
}
2826

2927
public function description(): string
3028
{
3129
$uriKey = $this->repository->uriKey();
3230
$modelName = class_basename($this->repository::$model);
33-
31+
3432
return "Create a new {$modelName} record in the {$uriKey} repository with the provided data.";
3533
}
3634

3735
public function schema(ToolInputSchema $schema): ToolInputSchema
3836
{
3937
$repositoryClass = get_class($this->repository);
4038
$repositoryClass::storeToolSchema($schema);
41-
39+
4240
return $schema;
4341
}
4442

4543
public function handle(array $arguments): ToolResult|Generator
4644
{
4745
$result = $this->repository->storeTool($arguments);
48-
46+
4947
return ToolResult::json($result);
5048
}
51-
}
49+
}

0 commit comments

Comments
 (0)