Skip to content

Commit 6d52fb7

Browse files
committed
#4 create class transform
1 parent 3d2cf83 commit 6d52fb7

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DenisKorbakov\LaravelDataScribe\Transforms\BodyParam;
6+
7+
use Knuckles\Scribe\Attributes\BodyParam;
8+
9+
final readonly class AtrTBodyParamTransform implements BodyParamTransform
10+
{
11+
/** @param array<int, array<string, mixed>> $attributeArguments */
12+
public function __construct(
13+
public array $attributeArguments,
14+
) {}
15+
16+
/** @return array<string, array<string, mixed>> */
17+
public function transform(): array
18+
{
19+
$argumentsDoc = [];
20+
21+
foreach ($this->attributeArguments as $arguments) {
22+
$bodyParam = new BodyParam(...$arguments);
23+
24+
$argumentsDoc[$bodyParam->name] = $bodyParam->toArray();
25+
}
26+
27+
return $argumentsDoc;
28+
}
29+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace DenisKorbakov\LaravelDataScribe\Transforms\BodyParam;
6+
7+
interface BodyParamTransform
8+
{
9+
/**
10+
* @return array<string, array<string, mixed>>
11+
*/
12+
public function transform(): array;
13+
}

0 commit comments

Comments
 (0)