2020-05-15 17:19:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace EchoPush;
|
|
|
|
|
|
|
|
use Wikimedia\Timestamp\ConvertibleTimestamp;
|
|
|
|
|
|
|
|
class Subscription {
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $provider;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
private $token;
|
|
|
|
|
|
|
|
/** @var ConvertibleTimestamp */
|
|
|
|
private $updated;
|
|
|
|
|
2020-08-03 18:27:47 +00:00
|
|
|
/** @var string|null */
|
|
|
|
private $topic;
|
|
|
|
|
2020-05-15 17:19:03 +00:00
|
|
|
/**
|
|
|
|
* Construct a subscription from a DB result row.
|
|
|
|
* @param object $row echo_push_subscription row from IResultWrapper::fetchRow
|
|
|
|
* @return Subscription
|
|
|
|
*/
|
|
|
|
public static function newFromRow( object $row ) {
|
|
|
|
return new self(
|
2020-06-02 23:20:06 +00:00
|
|
|
$row->epp_name,
|
2020-05-15 17:19:03 +00:00
|
|
|
$row->eps_token,
|
2020-08-03 18:27:47 +00:00
|
|
|
$row->eps_topic,
|
2020-05-15 17:19:03 +00:00
|
|
|
new ConvertibleTimestamp( $row->eps_updated )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $provider
|
|
|
|
* @param string $token
|
2020-08-03 18:27:47 +00:00
|
|
|
* @param string|null $topic
|
2020-05-15 17:19:03 +00:00
|
|
|
* @param ConvertibleTimestamp $updated
|
|
|
|
*/
|
2020-08-03 18:27:47 +00:00
|
|
|
public function __construct( string $provider, string $token, ?string $topic, ConvertibleTimestamp $updated ) {
|
2020-05-15 17:19:03 +00:00
|
|
|
$this->provider = $provider;
|
|
|
|
$this->token = $token;
|
2020-08-03 18:27:47 +00:00
|
|
|
$this->topic = $topic;
|
2020-05-15 17:19:03 +00:00
|
|
|
$this->updated = $updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return string provider */
|
|
|
|
public function getProvider(): string {
|
|
|
|
return $this->provider;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @return string token */
|
|
|
|
public function getToken(): string {
|
|
|
|
return $this->token;
|
|
|
|
}
|
|
|
|
|
2020-08-03 18:27:47 +00:00
|
|
|
/** @return string|null topic */
|
|
|
|
public function getTopic(): ?string {
|
|
|
|
return $this->topic;
|
|
|
|
}
|
|
|
|
|
2020-05-15 17:19:03 +00:00
|
|
|
/** @return ConvertibleTimestamp last updated timestamp */
|
|
|
|
public function getUpdated(): ConvertibleTimestamp {
|
|
|
|
return $this->updated;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|