Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
6 / 6
CRAP
100.00% covered (success)
100.00%
1 / 1
Subscription
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
6 / 6
6
100.00% covered (success)
100.00%
1 / 1
 newFromRow
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getProvider
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getToken
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getTopic
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getUpdated
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace MediaWiki\Extension\Notifications\Push;
4
5use Wikimedia\Timestamp\ConvertibleTimestamp;
6
7class Subscription {
8
9    /** @var string */
10    private $provider;
11
12    /** @var string */
13    private $token;
14
15    /** @var ConvertibleTimestamp */
16    private $updated;
17
18    /** @var string|null */
19    private $topic;
20
21    /**
22     * Construct a subscription from a DB result row.
23     * @param \stdClass $row echo_push_subscription row from IResultWrapper::fetchRow
24     * @return Subscription
25     */
26    public static function newFromRow( object $row ) {
27        return new self(
28            $row->epp_name,
29            $row->eps_token,
30            $row->ept_text,
31            new ConvertibleTimestamp( $row->eps_updated )
32        );
33    }
34
35    /**
36     * @param string $provider
37     * @param string $token
38     * @param string|null $topic
39     * @param ConvertibleTimestamp $updated
40     */
41    public function __construct( string $provider, string $token, ?string $topic, ConvertibleTimestamp $updated ) {
42        $this->provider = $provider;
43        $this->token = $token;
44        $this->topic = $topic;
45        $this->updated = $updated;
46    }
47
48    /** @return string provider */
49    public function getProvider(): string {
50        return $this->provider;
51    }
52
53    /** @return string token */
54    public function getToken(): string {
55        return $this->token;
56    }
57
58    /** @return string|null topic */
59    public function getTopic(): ?string {
60        return $this->topic;
61    }
62
63    /** @return ConvertibleTimestamp last updated timestamp */
64    public function getUpdated(): ConvertibleTimestamp {
65        return $this->updated;
66    }
67
68}