1 | <?php |
||
12 | class Card implements JsonSerializable |
||
13 | { |
||
14 | use HasButtons; |
||
15 | |||
16 | /** @var array Payload */ |
||
17 | protected $payload = []; |
||
18 | |||
19 | /** |
||
20 | * Create a Card. |
||
21 | * |
||
22 | * @param string $title |
||
23 | * |
||
24 | * @throws CouldNotCreateCard |
||
25 | * @return static |
||
26 | */ |
||
27 | public static function create(string $title = ''): self |
||
31 | |||
32 | /** |
||
33 | * Create Card constructor. |
||
34 | * |
||
35 | * @param string $title |
||
36 | * |
||
37 | * @throws CouldNotCreateCard |
||
38 | */ |
||
39 | public function __construct(string $title = '') |
||
45 | |||
46 | /** |
||
47 | * Set Button Title. |
||
48 | * |
||
49 | * @param string $title |
||
50 | * |
||
51 | * @throws CouldNotCreateCard |
||
52 | * @return $this |
||
53 | */ |
||
54 | public function title(string $title): self |
||
64 | |||
65 | /** |
||
66 | * Set Card Item Url. |
||
67 | * |
||
68 | * @param string $itemUrl |
||
69 | * |
||
70 | * @return $this |
||
71 | */ |
||
72 | public function url(string $itemUrl): self |
||
78 | |||
79 | /** |
||
80 | * Set Card Image Url. |
||
81 | * |
||
82 | * @param string $imageUrl Image ratio should be 1.91:1 |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | public function image(string $imageUrl): self |
||
92 | |||
93 | /** |
||
94 | * Set Card Subtitle. |
||
95 | * |
||
96 | * @param string $subtitle |
||
97 | * |
||
98 | * @throws CouldNotCreateCard |
||
99 | * @return $this |
||
100 | */ |
||
101 | public function subtitle(string $subtitle): self |
||
111 | |||
112 | /** |
||
113 | * Returns a payload for API request. |
||
114 | * |
||
115 | * @throws CouldNotCreateCard |
||
116 | * @return array |
||
117 | */ |
||
118 | public function toArray(): array |
||
130 | |||
131 | /** |
||
132 | * Convert the object into something JSON serializable. |
||
133 | * |
||
134 | * @throws CouldNotCreateCard |
||
135 | * @return mixed |
||
136 | */ |
||
137 | public function jsonSerialize() |
||
141 | } |
||
142 |