2016-09-06 15:26:39 +05:30
|
|
|
<?php
|
|
|
|
namespace api\modules\session\models\protocols;
|
|
|
|
|
|
|
|
abstract class BaseHasJoined implements HasJoinedInterface {
|
|
|
|
|
|
|
|
private $username;
|
2018-04-18 02:17:25 +05:30
|
|
|
|
2016-09-06 15:26:39 +05:30
|
|
|
private $serverId;
|
|
|
|
|
|
|
|
public function __construct(string $username, string $serverId) {
|
2017-09-19 22:36:16 +05:30
|
|
|
$this->username = trim($username);
|
|
|
|
$this->serverId = trim($serverId);
|
2016-09-06 15:26:39 +05:30
|
|
|
}
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function getUsername(): string {
|
2016-09-06 15:26:39 +05:30
|
|
|
return $this->username;
|
|
|
|
}
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function getServerId(): string {
|
2016-09-06 15:26:39 +05:30
|
|
|
return $this->serverId;
|
|
|
|
}
|
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
public function validate(): bool {
|
|
|
|
return !$this->isEmpty($this->username) && !$this->isEmpty($this->serverId);
|
|
|
|
}
|
2016-09-06 15:26:39 +05:30
|
|
|
|
2017-09-19 22:36:16 +05:30
|
|
|
private function isEmpty($value): bool {
|
|
|
|
return $value === null || $value === '';
|
2016-09-06 15:26:39 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
}
|