blob: de6c82eddba6e73305be0bb4c881ed972545d86f (
plain)
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
|
<?php
namespace App\Model;
use App\Model;
class Event
{
public int $id;
public ?string $type;
public \DateTime $time;
public ?string $payload;
public int $villageId;
public \DateTime $createdAt;
public \DateTime $updatedAt;
public function __construct(?\DateTime $time = null, int $villageId = 0)
{
$this->time = $time ?? new \DateTime();
$this->villageId = $villageId;
}
/* OOP */
public function cast(): Event
{
$class = Event::resolveType($this->type);
$object = new $class();
return Model::castToType($this, Event::resolveType($this->type));
}
public static function resolveType(string $type): string
{
return __NAMESPACE__ . '\\Event\\' . $type;
}
}
|