-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathStickerPartial.php
More file actions
81 lines (65 loc) · 2.12 KB
/
StickerPartial.php
File metadata and controls
81 lines (65 loc) · 2.12 KB
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
<?php
/*
* DiscordBot, PocketMine-MP Plugin.
*
* Licensed under the Open Software License version 3.0 (OSL-3.0)
* Copyright (C) 2020-present JaxkDev
*
* Discord :: JaxkDev
* Email :: JaxkDev@gmail.com
*/
namespace JaxkDev\DiscordBot\Models;
use JaxkDev\DiscordBot\Communication\BinarySerializable;
use JaxkDev\DiscordBot\Communication\BinaryStream;
use JaxkDev\DiscordBot\Plugin\Utils;
/**
* Partial sticker object.
*
* @implements BinarySerializable<StickerPartial>
* @link https://discord.com/developers/docs/resources/sticker#sticker-item-object-sticker-item-structure
*/
final class StickerPartial implements BinarySerializable{
private string $id;
private string $name;
private StickerFormatType $format_type;
public function __construct(string $id, string $name, StickerFormatType $format_type){
$this->setId($id);
$this->setName($name);
$this->setFormatType($format_type);
}
public function getId(): string{
return $this->id;
}
public function setId(string $id): void{
if(!Utils::validDiscordSnowflake($id)){
throw new \AssertionError("StickerPartial ID '$id' is invalid.");
}
$this->id = $id;
}
public function getName(): string{
return $this->name;
}
public function setName(string $name): void{
$this->name = $name;
}
public function getFormatType(): StickerFormatType{
return $this->format_type;
}
public function setFormatType(StickerFormatType $format_type): void{
$this->format_type = $format_type;
}
public function binarySerialize(): BinaryStream{
$stream = new BinaryStream();
$stream->putString($this->id);
$stream->putString($this->name);
$stream->putByte($this->format_type->value);
return $stream;
}
public static function fromBinary(BinaryStream $stream): self{
return new self(
$stream->getString(), // id
$stream->getString(), // name
StickerFormatType::from($stream->getByte()) // format_type
);
}
}