Skip to content

Commit 19918e3

Browse files
committed
Example DTO.
1 parent adc1d79 commit 19918e3

File tree

5 files changed

+80
-0
lines changed

5 files changed

+80
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebServCo\JSONAPI\DataTransfer\Example;
6+
7+
final readonly class ExampleAttributes
8+
{
9+
public function __construct(public ?string $routePart3, public string $userId)
10+
{
11+
}
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebServCo\JSONAPI\DataTransfer\Example;
6+
7+
use WebServCo\JSONAPI\Contract\Document\DataInterface;
8+
9+
final readonly class ExampleData implements DataInterface
10+
{
11+
public const string TYPE = 'example_data';
12+
13+
// @phpcs:ignore SlevomatCodingStandard.Classes.ForbiddenPublicProperty.ForbiddenPublicProperty
14+
public string $type;
15+
16+
public function __construct(public int $id, public ExampleAttributes $attributes, public ExampleDataItemMeta $meta)
17+
{
18+
$this->type = self::TYPE;
19+
}
20+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebServCo\JSONAPI\DataTransfer\Example;
6+
7+
use WebServCo\JSONAPI\Contract\Document\MetaInterface;
8+
9+
final readonly class ExampleDataItemMeta implements MetaInterface
10+
{
11+
public function __construct(public string $key)
12+
{
13+
}
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebServCo\JSONAPI\DataTransfer\Example;
6+
7+
use WebServCo\JSONAPI\Contract\Document\MetaInterface;
8+
9+
final readonly class ExampleDocumentMeta implements MetaInterface
10+
{
11+
public function __construct(public ?string $route, public string $version)
12+
{
13+
}
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace WebServCo\JSONAPI\DataTransfer\Example;
6+
7+
use WebServCo\JSONAPI\Contract\Data\ItemInterface;
8+
9+
final readonly class ExampleItem implements ItemInterface
10+
{
11+
public const string TYPE = 'example_item';
12+
13+
// @phpcs:ignore SlevomatCodingStandard.Classes.ForbiddenPublicProperty.ForbiddenPublicProperty
14+
public string $type;
15+
16+
public function __construct(public int $id, public ExampleAttributes $attributes, public ExampleDataItemMeta $meta)
17+
{
18+
$this->type = self::TYPE;
19+
}
20+
}

0 commit comments

Comments
 (0)