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


  /* 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;
  }
}