1 | <?php |
||
9 | class Card implements \JsonSerializable |
||
10 | { |
||
11 | use ButtonsTrait; |
||
12 | |||
13 | /** @var string Card Title */ |
||
14 | protected $title; |
||
15 | |||
16 | /** @var string Item Url */ |
||
17 | protected $image_url; |
||
18 | |||
19 | /** @var string Image Url */ |
||
20 | protected $item_url; |
||
21 | |||
22 | /** @var string Subtitle */ |
||
23 | protected $subtitle; |
||
24 | |||
25 | /** |
||
26 | * Create a Card. |
||
27 | * |
||
28 | * @return static |
||
29 | */ |
||
30 | public static function create($title = '') |
||
34 | |||
35 | /** |
||
36 | * Create Card constructor. |
||
37 | */ |
||
38 | public function __construct($title = '') |
||
42 | |||
43 | /** |
||
44 | * Set Button Title. |
||
45 | * |
||
46 | * @param $title |
||
47 | * @throws CouldNotCreateCard |
||
48 | * @return $this |
||
49 | */ |
||
50 | public function title($title) |
||
59 | |||
60 | /** |
||
61 | * Set Card Item Url. |
||
62 | * |
||
63 | * @param $item_url |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function url($item_url) |
||
72 | |||
73 | /** |
||
74 | * Set Card Image Url. |
||
75 | * |
||
76 | * @param $image_url |
||
77 | * Image ration should be 1.91:1 |
||
78 | * @return $this |
||
79 | */ |
||
80 | public function image($image_url) |
||
86 | |||
87 | /** |
||
88 | * Set Card Subtitle. |
||
89 | * |
||
90 | * @param $subtitle |
||
91 | * @throws CouldNotCreateCard |
||
92 | * @return $this |
||
93 | */ |
||
94 | public function subtitle($subtitle) |
||
103 | |||
104 | |||
105 | /** |
||
106 | * Builds payload and returns an array. |
||
107 | * |
||
108 | * @return array |
||
109 | * @throws CouldNotCreateCard |
||
110 | */ |
||
111 | public function toArray() |
||
138 | |||
139 | /** |
||
140 | * Convert the object into something JSON serializable. |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | public function jsonSerialize() |
||
148 | |||
149 | } |