Skip to content

Commit f461c2b

Browse files
committed
Extract HasProperty trait
1 parent 5880038 commit f461c2b

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/Schema/Concerns/HasProperty.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Tobyz\JsonApiServer\Schema\Concerns;
4+
5+
trait HasProperty
6+
{
7+
public ?string $property = null;
8+
9+
public function property(?string $property): static
10+
{
11+
$this->property = $property;
12+
13+
return $this;
14+
}
15+
}

src/Schema/Field/Field.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
namespace Tobyz\JsonApiServer\Schema\Field;
44

55
use Tobyz\JsonApiServer\Schema\Concerns\GetsValue;
6+
use Tobyz\JsonApiServer\Schema\Concerns\HasProperty;
67
use Tobyz\JsonApiServer\Schema\Concerns\HasVisibility;
78
use Tobyz\JsonApiServer\Schema\Concerns\SetsValue;
89

910
abstract class Field
1011
{
12+
use HasProperty;
1113
use HasVisibility;
1214
use GetsValue;
1315
use SetsValue;
1416

15-
public ?string $property = null;
1617
public bool $nullable = false;
1718
public ?string $description = null;
1819
public array $schema = [];
@@ -26,13 +27,6 @@ public static function make(string $name): static
2627
return new static($name);
2728
}
2829

29-
public function property(?string $property): static
30-
{
31-
$this->property = $property;
32-
33-
return $this;
34-
}
35-
3630
public function nullable(bool $nullable = true): static
3731
{
3832
$this->nullable = $nullable;

0 commit comments

Comments
 (0)