squareetlabs /
LaravelOpenVidu
| 1 | <?php |
||
| 2 | |||
| 3 | namespace SquareetLabs\LaravelOpenVidu; |
||
| 4 | |||
| 5 | use JsonSerializable; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Class Subscriber |
||
| 9 | * @package SquareetLabs\LaravelOpenVidu |
||
| 10 | * This is a backend representation of a published media stream (see [OpenVidu Browser Stream class](/api/openvidu-browser/classes/stream.html) |
||
| 11 | * {@see Connection::getPublishers()} |
||
| 12 | */ |
||
| 13 | class Subscriber implements JsonSerializable |
||
| 14 | { |
||
| 15 | |||
| 16 | /** @var string |
||
| 17 | * Unique identifier of the Stream {@link https://api/openvidu-browser/classes/stream.html} associated to this Subscriber. |
||
| 18 | */ |
||
| 19 | private $streamId; |
||
| 20 | |||
| 21 | /** @var string |
||
| 22 | * Unique identifier of the Stream {@link https://api/openvidu-browser/classes/stream.html} associated to the Publisher. |
||
| 23 | * Each Publisher is paired with only one Stream, so you can identify each Publisher by its |
||
| 24 | * Stream.streamId {@link https://api/openvidu-browser/classes/stream.html#streamid} |
||
| 25 | */ |
||
| 26 | private $publisherStreamId; |
||
| 27 | |||
| 28 | /** @var int |
||
| 29 | * Timestamp when this connection was established, in UTC milliseconds (ms since Jan 1, 1970, 00:00:00 UTC) |
||
| 30 | */ |
||
| 31 | private $createdAt; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Publisher constructor. |
||
| 35 | * @param string $streamId |
||
| 36 | * @param string $publisherStreamId |
||
| 37 | * @param int $createdAt |
||
| 38 | */ |
||
| 39 | public function __construct(string $streamId, string $publisherStreamId, int $createdAt) |
||
| 40 | { |
||
| 41 | $this->streamId = $streamId; |
||
| 42 | $this->publisherStreamId = $publisherStreamId; |
||
| 43 | $this->createdAt = $createdAt; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function __toString(): string |
||
| 47 | { |
||
| 48 | return $this->getStreamId(); |
||
| 49 | } |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | public function getStreamId(): string |
||
| 55 | { |
||
| 56 | return $this->streamId; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @return string |
||
| 61 | */ |
||
| 62 | public function getPublisherStreamId(): string |
||
| 63 | { |
||
| 64 | return $this->publisherStreamId; |
||
| 65 | } |
||
| 66 | |||
| 67 | |||
| 68 | /** |
||
| 69 | * Convert the model instance to JSON. |
||
| 70 | * |
||
| 71 | * @param int $options |
||
| 72 | * @return string |
||
| 73 | * |
||
| 74 | */ |
||
| 75 | public function toJson($options = 0): string |
||
| 76 | { |
||
| 77 | return json_encode($this->jsonSerialize(), $options); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Specify data which should be serialized to JSON |
||
| 82 | * @link https://php.net/manual/en/jsonserializable.jsonserialize.php |
||
| 83 | * @return mixed data which can be serialized by <b>json_encode</b>, |
||
| 84 | * which is a value of any type other than a resource. |
||
| 85 | * @since 5.4.0 |
||
| 86 | */ |
||
| 87 | public function jsonSerialize() |
||
| 88 | { |
||
| 89 | return $this->toArray(); |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Convert the model instance to an array. |
||
| 94 | * |
||
| 95 | * @return array |
||
| 96 | */ |
||
| 97 | public function toArray(): array |
||
| 98 | { |
||
| 99 | $array = [ |
||
| 100 | 'streamId' => $this->streamId, |
||
| 101 | 'publisherStreamId' => $this->publisherStreamId, |
||
| 102 | 'createdAt' => $this->createdAt |
||
| 103 | ]; |
||
| 104 | foreach ($array as $key => $value) { |
||
| 105 | if (is_null($value) || $value == '') { |
||
| 106 | unset($array[$key]); |
||
| 107 | } |
||
| 108 | } |
||
| 109 | return $array; |
||
| 110 | } |
||
| 111 | |||
| 112 | /** |
||
| 113 | * @param Publisher $other |
||
| 114 | * @return bool |
||
| 115 | */ |
||
| 116 | public function equalTo(Publisher $other): bool |
||
| 117 | { |
||
| 118 | return ( |
||
| 119 | $this->streamId === $other->getStreamId() && |
||
| 120 | $this->createdAt === $other->getCreatedAt() && |
||
| 121 | $this->publisherStreamId === $other->publisherStreamId() |
||
|
0 ignored issues
–
show
|
|||
| 122 | ); |
||
| 123 | } |
||
| 124 | |||
| 125 | /** |
||
| 126 | * @return int |
||
| 127 | */ |
||
| 128 | public function getCreatedAt(): int |
||
| 129 | { |
||
| 130 | return $this->createdAt; |
||
| 131 | } |
||
| 132 | } |
||
| 133 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.