Maknz\Slack\Message::setIcon PHP Method

setIcon() public method

Set the icon (either URL or emoji) we will post as.
public setIcon ( string $icon )
$icon string
    public function setIcon($icon)
    {
        if ($icon == null) {
            $this->icon = $this->iconType = null;
            return;
        }
        if (mb_substr($icon, 0, 1) == ':' && mb_substr($icon, mb_strlen($icon) - 1, 1) == ':') {
            $this->iconType = self::ICON_TYPE_EMOJI;
        } else {
            $this->iconType = self::ICON_TYPE_URL;
        }
        $this->icon = $icon;
        return $this;
    }

Usage Example

Beispiel #1
0
 /**
  * Create a new message with defaults.
  *
  * @return \Maknz\Slack\Message
  */
 public function createMessage()
 {
     $message = new Message($this);
     $message->setChannel($this->getDefaultChannel());
     $message->setUsername($this->getDefaultUsername());
     $message->setIcon($this->getDefaultIcon());
     $message->setAllowMarkdown($this->getAllowMarkdown());
     $message->setMarkdownInAttachments($this->getMarkdownInAttachments());
     return $message;
 }