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: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117:
<?php
namespace SAREhub\Client\Event;
use SAREhub\Client\User\User;
class BasicEvent implements Event
{
private $eventType;
private $time;
private $user;
private $properties = [];
protected function __construct($eventType)
{
$this->eventType = $eventType;
}
/**
* @param string $eventType
* @return BasicEvent
*/
public static function newInstanceOf($eventType)
{
return new self($eventType);
}
/**
* @param int $time
* @return $this
*/
public function withTime($time)
{
$this->time = $time;
return $this;
}
/**
* @param User $user
* @return $this
*/
public function withUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* @param array $properties
* @return $this
*/
public function withProperties(array $properties)
{
$this->properties = $properties;
return $this;
}
/**
* @param string $name
* @param mixed $value
* @return $this
*/
public function withProperty($name, $value)
{
$this->properties[$name] = $value;
return $this;
}
public function getType()
{
return $this->eventType;
}
/**
* @deprecated Use getType
*/
public function getEventType()
{
return $this->eventType;
}
public function getTime()
{
return $this->time;
}
public function getUser()
{
return $this->user;
}
public function hasUser()
{
return $this->user !== null;
}
public function getProperties()
{
return $this->properties;
}
public function getProperty($name)
{
if ($this->hasProperty($name)) {
return $this->properties[$name];
}
throw new EventPropertyNotFoundException($this, $name);
}
public function hasProperty($name)
{
return isset($this->properties[$name]);
}
}