maknz /
slack
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Maknz\Slack; |
||
| 4 | |||
| 5 | use InvalidArgumentException; |
||
| 6 | |||
| 7 | class AttachmentAction |
||
| 8 | { |
||
| 9 | const TYPE_BUTTON = 'button'; |
||
| 10 | |||
| 11 | const STYLE_DEFAULT = 'default'; |
||
| 12 | const STYLE_PRIMARY = 'primary'; |
||
| 13 | const STYLE_DANGER = 'danger'; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * The required name field of the action. The name will be returned to your Action URL. |
||
| 17 | * |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $name; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * The required label for the action. |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $text; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Button style. |
||
| 31 | * |
||
| 32 | * @var string |
||
| 33 | */ |
||
| 34 | protected $style; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * The required type of the action. |
||
| 38 | * |
||
| 39 | * @var string |
||
| 40 | */ |
||
| 41 | protected $type = self::TYPE_BUTTON; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Optional value. It will be sent to your Action URL. |
||
| 45 | * |
||
| 46 | * @var string |
||
| 47 | */ |
||
| 48 | protected $value; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Confirmation field. |
||
| 52 | * |
||
| 53 | * @var ActionConfirmation |
||
| 54 | */ |
||
| 55 | protected $confirm; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Instantiate a new AttachmentAction. |
||
| 59 | * |
||
| 60 | * @param array $attributes |
||
| 61 | * @return void |
||
|
0 ignored issues
–
show
|
|||
| 62 | */ |
||
| 63 | public function __construct(array $attributes) |
||
| 64 | { |
||
| 65 | if (isset($attributes['name'])) { |
||
| 66 | $this->setName($attributes['name']); |
||
| 67 | } |
||
| 68 | |||
| 69 | if (isset($attributes['text'])) { |
||
| 70 | $this->setText($attributes['text']); |
||
| 71 | } |
||
| 72 | |||
| 73 | if (isset($attributes['style'])) { |
||
| 74 | $this->setStyle($attributes['style']); |
||
| 75 | } |
||
| 76 | |||
| 77 | if (isset($attributes['type'])) { |
||
| 78 | $this->setType($attributes['type']); |
||
| 79 | } |
||
| 80 | |||
| 81 | if (isset($attributes['value'])) { |
||
| 82 | $this->setValue($attributes['value']); |
||
| 83 | } |
||
| 84 | |||
| 85 | if (isset($attributes['confirm'])) { |
||
| 86 | $this->setConfirm($attributes['confirm']); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @return string |
||
| 92 | */ |
||
| 93 | public function getName() |
||
| 94 | { |
||
| 95 | return $this->name; |
||
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @param string $name |
||
| 100 | * @return AttachmentAction |
||
| 101 | */ |
||
| 102 | public function setName($name) |
||
| 103 | { |
||
| 104 | $this->name = $name; |
||
| 105 | |||
| 106 | return $this; |
||
| 107 | } |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @return string |
||
| 111 | */ |
||
| 112 | public function getText() |
||
| 113 | { |
||
| 114 | return $this->text; |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @param string $text |
||
| 119 | * @return AttachmentAction |
||
| 120 | */ |
||
| 121 | public function setText($text) |
||
| 122 | { |
||
| 123 | $this->text = $text; |
||
| 124 | |||
| 125 | return $this; |
||
| 126 | } |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @return string |
||
| 130 | */ |
||
| 131 | public function getStyle() |
||
| 132 | { |
||
| 133 | return $this->style; |
||
| 134 | } |
||
| 135 | |||
| 136 | /** |
||
| 137 | * @param string $style |
||
| 138 | * @return AttachmentAction |
||
| 139 | */ |
||
| 140 | public function setStyle($style) |
||
| 141 | { |
||
| 142 | $this->style = $style; |
||
| 143 | |||
| 144 | return $this; |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @return string |
||
| 149 | */ |
||
| 150 | public function getType() |
||
| 151 | { |
||
| 152 | return $this->type; |
||
| 153 | } |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @param string $type |
||
| 157 | * @return AttachmentAction |
||
| 158 | */ |
||
| 159 | public function setType($type) |
||
| 160 | { |
||
| 161 | $this->type = $type; |
||
| 162 | |||
| 163 | return $this; |
||
| 164 | } |
||
| 165 | |||
| 166 | /** |
||
| 167 | * @return string |
||
| 168 | */ |
||
| 169 | public function getValue() |
||
| 170 | { |
||
| 171 | return $this->value; |
||
| 172 | } |
||
| 173 | |||
| 174 | /** |
||
| 175 | * @param string $value |
||
| 176 | * @return AttachmentAction |
||
| 177 | */ |
||
| 178 | public function setValue($value) |
||
| 179 | { |
||
| 180 | $this->value = $value; |
||
| 181 | |||
| 182 | return $this; |
||
| 183 | } |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @return ActionConfirmation |
||
| 187 | */ |
||
| 188 | public function getConfirm() |
||
| 189 | { |
||
| 190 | return $this->confirm; |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @param ActionConfirmation|array $confirm |
||
| 195 | * @return AttachmentAction |
||
| 196 | */ |
||
| 197 | public function setConfirm($confirm) |
||
| 198 | { |
||
| 199 | if ($confirm instanceof ActionConfirmation) { |
||
| 200 | $this->confirm = $confirm; |
||
| 201 | |||
| 202 | return $this; |
||
| 203 | } elseif (is_array($confirm)) { |
||
| 204 | $this->confirm = new ActionConfirmation($confirm); |
||
| 205 | |||
| 206 | return $this; |
||
| 207 | } |
||
| 208 | |||
| 209 | throw new InvalidArgumentException('The action confirmation must be an instance of Maknz\Slack\ActionConfirmation or a keyed array'); |
||
| 210 | } |
||
| 211 | |||
| 212 | /** |
||
| 213 | * Get the array representation of this attachment action. |
||
| 214 | * |
||
| 215 | * @return array |
||
| 216 | */ |
||
| 217 | public function toArray() |
||
| 218 | { |
||
| 219 | return [ |
||
| 220 | 'name' => $this->getName(), |
||
| 221 | 'text' => $this->getText(), |
||
| 222 | 'style' => $this->getStyle(), |
||
| 223 | 'type' => $this->getType(), |
||
| 224 | 'value' => $this->getValue(), |
||
| 225 | 'confirm' => $this->getConfirm()->toArray(), |
||
| 226 | ]; |
||
| 227 | } |
||
| 228 | } |
||
| 229 |
Adding a
@returnannotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.