public static function fromOptions(array $options) { if (!isset($options['fallback'])) { throw new SlackBotException("'fallback' is mandatory for\n attachments"); } $attachment = new self($options['fallback']); if (isset($options['color'])) { $attachment->setColor($options['color']); unset($options['color']); } $attachment->options = array_replace($attachment->options, $options); return $attachment; }
/** * @author WN * @param string|null $content * @param int|null $color * @param int|null $option * @param int|null $bgcolor * @return Char */ public static function make($content = null, $color = null, $option = null, $bgcolor = null, $default = null) { $obj = new self($content); if ($content !== null) { $obj->setContent($content); } if ($color !== null) { $obj->setColor($color); } if ($bgcolor !== null) { $obj->setBgcolor($bgcolor); } $obj->setDefault($default); return $obj; }
/** * @param string $message * @param string|null $format * @param string|null $color * @param bool|null $notify * * @return Response */ public static function create($message, $format = null, $color = null, $notify = null) { $response = new self(); $response->setMessage($message); if ($format !== null) { $response->setMessageFormat($format); } if ($color !== null) { $response->setColor($color); } if ($notify !== null) { $response->setNotify($notify); } return $response; }