summaryrefslogtreecommitdiff
path: root/src/Model/Event.php
blob: aa235f9ba155c3220e069cdc8b8baf729441134b (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
<?php

namespace App\Model;

use App\Model;

class Event
{
  public int $id;

  public string $type;
  public \DateTime $time;
  public string $payload;

  public int $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;
  }
}