43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
class RsvMembershipProgram {
|
||
|
|
public ?int $id;
|
||
|
|
|
||
|
|
public string $name;
|
||
|
|
|
||
|
|
public bool $active;
|
||
|
|
|
||
|
|
public static function schema(): array {
|
||
|
|
return [
|
||
|
|
'type' => 'object',
|
||
|
|
'properties' => [
|
||
|
|
'id' => ['type' => 'integer', 'readonly' => true],
|
||
|
|
'name' => ['type' => 'string', 'required' => true, 'minLength' => 1],
|
||
|
|
'active' => ['type' => 'boolean', 'default' => true],
|
||
|
|
],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public static function from_array(array $data): self {
|
||
|
|
return new self(
|
||
|
|
intval($data['id'] ?? null),
|
||
|
|
$data['name'] ?? '',
|
||
|
|
boolval($data['active'] ?? true)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function __construct(?int $id, string $name, bool $active = true) {
|
||
|
|
$this->id = $id;
|
||
|
|
$this->name = $name;
|
||
|
|
$this->active = $active;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function to_array() {
|
||
|
|
return [
|
||
|
|
'id' => $this->id,
|
||
|
|
'name' => $this->name,
|
||
|
|
'active' => $this->active,
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|