-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPropertyType.php
79 lines (74 loc) · 2.29 KB
/
PropertyType.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types = 1);
namespace TypeSchema\Model;
use PSX\Schema\Attribute\DerivedType;
use PSX\Schema\Attribute\Description;
use PSX\Schema\Attribute\Discriminator;
#[Description('Base property type')]
#[Discriminator('type')]
#[DerivedType(AnyPropertyType::class, 'any')]
#[DerivedType(ArrayPropertyType::class, 'array')]
#[DerivedType(BooleanPropertyType::class, 'boolean')]
#[DerivedType(GenericPropertyType::class, 'generic')]
#[DerivedType(IntegerPropertyType::class, 'integer')]
#[DerivedType(MapPropertyType::class, 'map')]
#[DerivedType(NumberPropertyType::class, 'number')]
#[DerivedType(ReferencePropertyType::class, 'reference')]
#[DerivedType(StringPropertyType::class, 'string')]
abstract class PropertyType implements \JsonSerializable, \PSX\Record\RecordableInterface
{
#[Description('')]
protected ?bool $deprecated = null;
#[Description('')]
protected ?string $description = null;
#[Description('')]
protected ?bool $nullable = null;
#[Description('')]
protected ?string $type = null;
public function setDeprecated(?bool $deprecated) : void
{
$this->deprecated = $deprecated;
}
public function getDeprecated() : ?bool
{
return $this->deprecated;
}
public function setDescription(?string $description) : void
{
$this->description = $description;
}
public function getDescription() : ?string
{
return $this->description;
}
public function setNullable(?bool $nullable) : void
{
$this->nullable = $nullable;
}
public function getNullable() : ?bool
{
return $this->nullable;
}
public function setType(?string $type) : void
{
$this->type = $type;
}
public function getType() : ?string
{
return $this->type;
}
public function toRecord() : \PSX\Record\RecordInterface
{
/** @var \PSX\Record\Record<mixed> $record */
$record = new \PSX\Record\Record();
$record->put('deprecated', $this->deprecated);
$record->put('description', $this->description);
$record->put('nullable', $this->nullable);
$record->put('type', $this->type);
return $record;
}
public function jsonSerialize() : object
{
return (object) $this->toRecord()->getAll();
}
}