code
stringlengths
31
1.39M
docstring
stringlengths
23
16.8k
func_name
stringlengths
1
126
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
166
url
stringlengths
50
220
license
stringclasses
7 values
public function setAuthorIcon($author_icon) { $this->author_icon = $author_icon; return $this; }
Set the author icon to use for the attachment. @param string $author_icon @return $this
setAuthorIcon
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function getFields() { return $this->fields; }
Get the fields for the attachment. @return array
getFields
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function setFields(array $fields) { $this->clearFields(); foreach ($fields as $field) { $this->addField($field); } return $this; }
Set the fields for the attachment. @param array $fields @return $this
setFields
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function addField($field) { if ($field instanceof AttachmentField) { $this->fields[] = $field; return $this; } elseif (is_array($field)) { $this->fields[] = new AttachmentField($field); return $this; } throw new InvalidArgumentException('The attachment field must be an instance of Maknz\Slack\AttachmentField or a keyed array'); }
Add a field to the attachment. @param mixed $field @return $this
addField
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function clearFields() { $this->fields = []; return $this; }
Clear the fields for the attachment. @return $this
clearFields
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function clearActions() { $this->actions = []; return $this; }
Clear the actions for the attachment. @return $this
clearActions
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function getMarkdownFields() { return $this->markdown_fields; }
Get the fields Slack should interpret in its Markdown-like language. @return array
getMarkdownFields
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function setMarkdownFields(array $fields) { $this->markdown_fields = $fields; return $this; }
Set the fields Slack should interpret in its Markdown-like language. @param array $fields @return $this
setMarkdownFields
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function getActions() { return $this->actions; }
Get the collection of actions (buttons) to include in the attachment. @return AttachmentAction[]
getActions
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function setActions($actions) { $this->clearActions(); foreach ($actions as $action) { $this->addAction($action); } return $this; }
Set the collection of actions (buttons) to include in the attachment. @param array $actions @return Attachment
setActions
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function addAction($action) { if ($action instanceof AttachmentAction) { $this->actions[] = $action; return $this; } elseif (is_array($action)) { $this->actions[] = new AttachmentAction($action); return $this; } throw new InvalidArgumentException('The attachment action must be an instance of Maknz\Slack\AttachmentAction or a keyed array'); }
Add an action to the attachment. @param mixed $action @return $this
addAction
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function toArray() { $data = [ 'fallback' => $this->getFallback(), 'text' => $this->getText(), 'pretext' => $this->getPretext(), 'color' => $this->getColor(), 'footer' => $this->getFooter(), 'footer_icon' => $this->getFooterIcon(), 'ts' => $this->getTimestamp() ? $this->getTimestamp()->getTimestamp() : null, 'mrkdwn_in' => $this->getMarkdownFields(), 'image_url' => $this->getImageUrl(), 'thumb_url' => $this->getThumbUrl(), 'title' => $this->getTitle(), 'title_link' => $this->getTitleLink(), 'author_name' => $this->getAuthorName(), 'author_link' => $this->getAuthorLink(), 'author_icon' => $this->getAuthorIcon(), ]; $data['fields'] = $this->getFieldsAsArrays(); $data['actions'] = $this->getActionsAsArrays(); return $data; }
Convert this attachment to its array representation. @return array
toArray
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
protected function getFieldsAsArrays() { $fields = []; foreach ($this->getFields() as $field) { $fields[] = $field->toArray(); } return $fields; }
Iterates over all fields in this attachment and returns them in their array form. @return array
getFieldsAsArrays
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
protected function getActionsAsArrays() { $actions = []; foreach ($this->getActions() as $action) { $actions[] = $action->toArray(); } return $actions; }
Iterates over all actions in this attachment and returns them in their array form. @return array
getActionsAsArrays
php
maknz/slack
src/Attachment.php
https://github.com/maknz/slack/blob/master/src/Attachment.php
BSD-2-Clause
public function __construct(array $attributes) { if (isset($attributes['name'])) { $this->setName($attributes['name']); } if (isset($attributes['text'])) { $this->setText($attributes['text']); } if (isset($attributes['style'])) { $this->setStyle($attributes['style']); } if (isset($attributes['type'])) { $this->setType($attributes['type']); } if (isset($attributes['value'])) { $this->setValue($attributes['value']); } if (isset($attributes['confirm'])) { $this->setConfirm($attributes['confirm']); } }
Instantiate a new AttachmentAction. @param array $attributes @return void
__construct
php
maknz/slack
src/AttachmentAction.php
https://github.com/maknz/slack/blob/master/src/AttachmentAction.php
BSD-2-Clause
public function setConfirm($confirm) { if ($confirm instanceof ActionConfirmation) { $this->confirm = $confirm; return $this; } elseif (is_array($confirm)) { $this->confirm = new ActionConfirmation($confirm); return $this; } throw new InvalidArgumentException('The action confirmation must be an instance of Maknz\Slack\ActionConfirmation or a keyed array'); }
@param ActionConfirmation|array $confirm @return AttachmentAction
setConfirm
php
maknz/slack
src/AttachmentAction.php
https://github.com/maknz/slack/blob/master/src/AttachmentAction.php
BSD-2-Clause
public function toArray() { return [ 'name' => $this->getName(), 'text' => $this->getText(), 'style' => $this->getStyle(), 'type' => $this->getType(), 'value' => $this->getValue(), 'confirm' => $this->getConfirm()->toArray(), ]; }
Get the array representation of this attachment action. @return array
toArray
php
maknz/slack
src/AttachmentAction.php
https://github.com/maknz/slack/blob/master/src/AttachmentAction.php
BSD-2-Clause
public function __construct(array $attributes) { if (isset($attributes['title'])) { $this->setTitle($attributes['title']); } if (isset($attributes['value'])) { $this->setValue($attributes['value']); } if (isset($attributes['short'])) { $this->setShort($attributes['short']); } }
Instantiate a new AttachmentField. @param array $attributes @return void
__construct
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function getTitle() { return $this->title; }
Get the title of the field. @return string
getTitle
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function setTitle($title) { $this->title = $title; return $this; }
Set the title of the field. @param string $title @return $this
setTitle
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function getValue() { return $this->value; }
Get the value of the field. @return string
getValue
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function setValue($value) { $this->value = $value; return $this; }
Set the value of the field. @param string $value @return $this
setValue
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function getShort() { return $this->short; }
Get whether this field is short enough for displaying side-by-side with other fields. @return bool
getShort
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function setShort($value) { $this->short = (bool) $value; return $this; }
Set whether this field is short enough for displaying side-by-side with other fields. @param string $value @return $this
setShort
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function toArray() { return [ 'title' => $this->getTitle(), 'value' => $this->getValue(), 'short' => $this->getShort(), ]; }
Get the array representation of this attachment field. @return array
toArray
php
maknz/slack
src/AttachmentField.php
https://github.com/maknz/slack/blob/master/src/AttachmentField.php
BSD-2-Clause
public function __construct($endpoint, array $attributes = [], Guzzle $guzzle = null) { $this->endpoint = $endpoint; if (isset($attributes['channel'])) { $this->setDefaultChannel($attributes['channel']); } if (isset($attributes['username'])) { $this->setDefaultUsername($attributes['username']); } if (isset($attributes['icon'])) { $this->setDefaultIcon($attributes['icon']); } if (isset($attributes['link_names'])) { $this->setLinkNames($attributes['link_names']); } if (isset($attributes['unfurl_links'])) { $this->setUnfurlLinks($attributes['unfurl_links']); } if (isset($attributes['unfurl_media'])) { $this->setUnfurlMedia($attributes['unfurl_media']); } if (isset($attributes['allow_markdown'])) { $this->setAllowMarkdown($attributes['allow_markdown']); } if (isset($attributes['markdown_in_attachments'])) { $this->setMarkdownInAttachments($attributes['markdown_in_attachments']); } $this->guzzle = $guzzle ?: new Guzzle; }
Instantiate a new Client. @param string $endpoint @param array $attributes @return void
__construct
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function __call($name, $arguments) { return call_user_func_array([$this->createMessage(), $name], $arguments); }
Pass any unhandled methods through to a new Message instance. @param string $name The name of the method @param array $arguments The method arguments @return \Maknz\Slack\Message
__call
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getEndpoint() { return $this->endpoint; }
Get the Slack endpoint. @return string
getEndpoint
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setEndpoint($endpoint) { $this->endpoint = $endpoint; }
Set the Slack endpoint. @param string $endpoint @return void
setEndpoint
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getDefaultChannel() { return $this->channel; }
Get the default channel messages will be created for. @return string
getDefaultChannel
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setDefaultChannel($channel) { $this->channel = $channel; }
Set the default channel messages will be created for. @param string $channel @return void
setDefaultChannel
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getDefaultUsername() { return $this->username; }
Get the default username messages will be created for. @return string
getDefaultUsername
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setDefaultUsername($username) { $this->username = $username; }
Set the default username messages will be created for. @param string $username @return void
setDefaultUsername
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getDefaultIcon() { return $this->icon; }
Get the default icon messages will be created with. @return string
getDefaultIcon
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setDefaultIcon($icon) { $this->icon = $icon; }
Set the default icon messages will be created with. @param string $icon @return void
setDefaultIcon
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getLinkNames() { return $this->link_names; }
Get whether messages sent will have names (like @regan) will be converted into links. @return bool
getLinkNames
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setLinkNames($value) { $this->link_names = (bool) $value; }
Set whether messages sent will have names (like @regan) will be converted into links. @param bool $value @return void
setLinkNames
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getUnfurlLinks() { return $this->unfurl_links; }
Get whether text links should be unfurled. @return bool
getUnfurlLinks
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setUnfurlLinks($value) { $this->unfurl_links = (bool) $value; }
Set whether text links should be unfurled. @param bool $value @return void
setUnfurlLinks
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getUnfurlMedia() { return $this->unfurl_media; }
Get whether media links should be unfurled. @return bool
getUnfurlMedia
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setUnfurlMedia($value) { $this->unfurl_media = (bool) $value; }
Set whether media links should be unfurled. @param bool $value @return void
setUnfurlMedia
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getAllowMarkdown() { return $this->allow_markdown; }
Get whether message text should be formatted with Slack's Markdown-like language. @return bool
getAllowMarkdown
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setAllowMarkdown($value) { $this->allow_markdown = (bool) $value; }
Set whether message text should be formatted with Slack's Markdown-like language. @param bool $value @return void
setAllowMarkdown
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function getMarkdownInAttachments() { return $this->markdown_in_attachments; }
Get the attachment fields which should be formatted in Slack's Markdown-like language. @return array
getMarkdownInAttachments
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function setMarkdownInAttachments(array $fields) { $this->markdown_in_attachments = $fields; }
Set the attachment fields which should be formatted in Slack's Markdown-like language. @param array $fields @return void
setMarkdownInAttachments
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
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; }
Create a new message with defaults. @return \Maknz\Slack\Message
createMessage
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function sendMessage(Message $message) { $payload = $this->preparePayload($message); $encoded = json_encode($payload, JSON_UNESCAPED_UNICODE); if ($encoded === false) { throw new RuntimeException(sprintf('JSON encoding error %s: %s', json_last_error(), json_last_error_msg())); } $this->guzzle->post($this->endpoint, ['body' => $encoded]); }
Send a message. @param \Maknz\Slack\Message $message @return void
sendMessage
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function preparePayload(Message $message) { $payload = [ 'text' => $message->getText(), 'channel' => $message->getChannel(), 'username' => $message->getUsername(), 'link_names' => $this->getLinkNames() ? 1 : 0, 'unfurl_links' => $this->getUnfurlLinks(), 'unfurl_media' => $this->getUnfurlMedia(), 'mrkdwn' => $message->getAllowMarkdown(), ]; if ($icon = $message->getIcon()) { $payload[$message->getIconType()] = $icon; } $payload['attachments'] = $this->getAttachmentsAsArrays($message); return $payload; }
Prepares the payload to be sent to the webhook. @param \Maknz\Slack\Message $message The message to send @return array
preparePayload
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
protected function getAttachmentsAsArrays(Message $message) { $attachments = []; foreach ($message->getAttachments() as $attachment) { $attachments[] = $attachment->toArray(); } return $attachments; }
Get the attachments in array form. @param \Maknz\Slack\Message $message @return array
getAttachmentsAsArrays
php
maknz/slack
src/Client.php
https://github.com/maknz/slack/blob/master/src/Client.php
BSD-2-Clause
public function __construct(Client $client) { $this->client = $client; }
Instantiate a new Message. @param \Maknz\Slack\Client $client @return void
__construct
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getText() { return $this->text; }
Get the message text. @return string
getText
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function setText($text) { $this->text = $text; return $this; }
Set the message text. @param string $text @return $this
setText
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getChannel() { return $this->channel; }
Get the channel we will post to. @return string
getChannel
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function setChannel($channel) { $this->channel = $channel; return $this; }
Set the channel we will post to. @param string $channel @return $this
setChannel
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getUsername() { return $this->username; }
Get the username we will post as. @return string
getUsername
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function setUsername($username) { $this->username = $username; return $this; }
Set the username we will post as. @param string $username @return $this
setUsername
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getIcon() { return $this->icon; }
Get the icon (either URL or emoji) we will post as. @return string
getIcon
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
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; }
Set the icon (either URL or emoji) we will post as. @param string $icon @return $this
setIcon
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getIconType() { return $this->iconType; }
Get the icon type being used, if an icon is set. @return string
getIconType
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getAllowMarkdown() { return $this->allow_markdown; }
Get whether message text should be formatted with Slack's Markdown-like language. @return bool
getAllowMarkdown
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function setAllowMarkdown($value) { $this->allow_markdown = (bool) $value; return $this; }
Set whether message text should be formatted with Slack's Markdown-like language. @param bool $value @return void
setAllowMarkdown
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function enableMarkdown() { $this->setAllowMarkdown(true); return $this; }
Enable Markdown formatting for the message. @return void
enableMarkdown
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function disableMarkdown() { $this->setAllowMarkdown(false); return $this; }
Disable Markdown formatting for the message. @return void
disableMarkdown
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getMarkdownInAttachments() { return $this->markdown_in_attachments; }
Get the attachment fields which should be formatted in Slack's Markdown-like language. @return array
getMarkdownInAttachments
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function setMarkdownInAttachments(array $fields) { $this->markdown_in_attachments = $fields; return $this; }
Set the attachment fields which should be formatted in Slack's Markdown-like language. @param array $fields @return void
setMarkdownInAttachments
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function from($username) { $this->setUsername($username); return $this; }
Change the name of the user the post will be made as. @param string $username @return $this
from
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function to($channel) { $this->setChannel($channel); return $this; }
Change the channel the post will be made to. @param string $channel @return $this
to
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function withIcon($icon) { $this->setIcon($icon); return $this; }
Chainable method for setting the icon. @param string $icon @return $this
withIcon
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function attach($attachment) { if ($attachment instanceof Attachment) { $this->attachments[] = $attachment; return $this; } elseif (is_array($attachment)) { $attachmentObject = new Attachment($attachment); if (! isset($attachment['mrkdwn_in'])) { $attachmentObject->setMarkdownFields($this->getMarkdownInAttachments()); } $this->attachments[] = $attachmentObject; return $this; } throw new InvalidArgumentException('Attachment must be an instance of Maknz\\Slack\\Attachment or a keyed array'); }
Add an attachment to the message. @param mixed $attachment @return $this
attach
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function getAttachments() { return $this->attachments; }
Get the attachments for the message. @return array
getAttachments
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function setAttachments(array $attachments) { $this->clearAttachments(); foreach ($attachments as $attachment) { $this->attach($attachment); } return $this; }
Set the attachments for the message. @param array $attachments @return $this
setAttachments
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function clearAttachments() { $this->attachments = []; return $this; }
Remove all attachments for the message. @return $this
clearAttachments
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
public function send($text = null) { if ($text) { $this->setText($text); } $this->client->sendMessage($this); return $this; }
Send the message. @param string $text The text to send @return void
send
php
maknz/slack
src/Message.php
https://github.com/maknz/slack/blob/master/src/Message.php
BSD-2-Clause
protected static function getFacadeAccessor() { return 'desktop.notifier'; }
Get the registered name of the component. @return string
getFacadeAccessor
php
nunomaduro/laravel-desktop-notifier
src/Facades/Notifier.php
https://github.com/nunomaduro/laravel-desktop-notifier/blob/master/src/Facades/Notifier.php
MIT
public function __construct(mixed $string = '', $encoding = null) { $this->encoding = $encoding ?? Config\Str::getEncoding(); $this->string = mb_convert_encoding((string) $string, $this->encoding); }
Create a new Str object. @param string|int| $string A string @param string $encoding The internal encoding @return \PHLAK\Twine\Str
__construct
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public function __toString(): string { return $this->string; }
Magic toString method. Returns the object as a string. @return string The string
__toString
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public function __serialize(): array { return [ 'string' => $this->string, 'encoding' => $this->encoding, ]; }
@return array{string: string, encoding: string}
__serialize
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public function __unserialize(array $data): void { $this->string = $data['string']; $this->encoding = $data['encoding']; }
@param array{string: string, encoding: string} $data
__unserialize
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public static function make(...$parameters): self { return new self(...$parameters); }
Static make constructor. @param mixed ...$parameters The parameters
make
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public function jsonSerialize(): string { return $this->string; }
Returns the object as a string when json_encode is called.
jsonSerialize
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public function encoding(string $encoding): self { return new self($this->string, $encoding); }
Set the internal character encoding. @param string $encoding The desired character encoding
encoding
php
PHLAK/Twine
src/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Str.php
MIT
public static function setEncoding(string $encoding): void { if (! in_array($encoding, mb_list_encodings())) { throw new ConfigException('Invalid encoding specified'); } self::$encoding = $encoding; }
Set the default internal character encoding. @param string $encoding The desired character encoding
setEncoding
php
PHLAK/Twine
src/Config/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Config/Str.php
MIT
public static function getEncoding(): string { return self::$encoding; }
Get the default internal character encoding.
getEncoding
php
PHLAK/Twine
src/Config/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Config/Str.php
MIT
function str($string) { return new PHLAK\Twine\Str($string); }
Create a Twine string object. @param string|int|float|bool $string A string @return \PHLAK\Twine\Str
str
php
PHLAK/Twine
src/Support/helpers.php
https://github.com/PHLAK/Twine/blob/master/src/Support/helpers.php
MIT
public static function characters(string $string): array { return (array) preg_split('//u', $string, -1, PREG_SPLIT_NO_EMPTY); }
Split a string into an array of characters. @param string $string A String @return list<string>
characters
php
PHLAK/Twine
src/Support/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Support/Str.php
MIT
public static function words(string $string): array { preg_match_all('/\p{Lu}?[\p{Ll}0-9]+/u', $string, $matches); return $matches[0]; }
Split an string into an array of words. @param string $string A String @return list<string>
words
php
PHLAK/Twine
src/Support/Str.php
https://github.com/PHLAK/Twine/blob/master/src/Support/Str.php
MIT
public function first(int $count): self { return $this->substring(0, $count); }
Return a number of characters from the start of the string. @param int $count The number of characters to be returned
first
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function last(int $count): self { return $this->substring(-$count); }
Return a number of characters from the end of the string. @param int $count The number of characters to be returned
last
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function trimLeft(string $mask = " \t\n\r\0\x0B"): self { return $this->trim($mask, Config\Trim::LEFT); }
Remove whitespace or a specific set of characters from the beginning of the string. @param string $mask A list of characters to be stripped (default: " \t\n\r\0\x0B")
trimLeft
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function trimRight(string $mask = " \t\n\r\0\x0B"): self { return $this->trim($mask, Config\Trim::RIGHT); }
Remove whitespace or a specific set of characters from the end of the string. @param string $mask A list of characters to be stripped (default: " \t\n\r\0\x0B")
trimRight
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function uppercaseFirst(): self { return $this->uppercase(Config\Uppercase::FIRST); }
Convert the first character of the string to uppercase.
uppercaseFirst
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function uppercaseWords(): self { return $this->uppercase(Config\Uppercase::WORDS); }
Convert the first character of each word in the string to uppercase.
uppercaseWords
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function lowercaseFirst(): self { return $this->lowercase(Config\Lowercase::FIRST); }
Convert the first letter of the string to lowercase.
lowercaseFirst
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function lowercaseWords(): self { return $this->lowercase(Config\Lowercase::WORDS); }
Convert the first letter of the string to lowercase.
lowercaseWords
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function wrapSoft(int $width, string $break = "\n"): self { return $this->wrap($width, $break, Config\Wrap::SOFT); }
Wrap the string after the first whitespace character after a given number of characters. @param int $width Number of characters at which to wrap @param string $break Character used to break the string
wrapSoft
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function wrapHard($width, $break = "\n"): self { return $this->wrap($width, $break, Config\Wrap::HARD); }
Wrap the string after an exact number of characters. @param int $width Number of characters at which to wrap @param string $break Character used to break the string
wrapHard
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function padRight(int $length, string $padding = ' '): self { return $this->pad($length, $padding, Config\Pad::RIGHT); }
Pad right side of the string to a specific length. @param int $length Length to pad the string to @param string $padding Character to pad the string with
padRight
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function padLeft(int $length, string $padding = ' '): self { return $this->pad($length, $padding, Config\Pad::LEFT); }
Pad left side of the string to a specific length. @param int $length Length to pad the string to @param string $padding Character to pad the string with
padLeft
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function padBoth(int $length, string $padding = ' '): self { return $this->pad($length, $padding, Config\Pad::BOTH); }
Pad both sides of the string to a specific length. @param int $length Length to pad the string to @param string $padding Character to pad the string with
padBoth
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT
public function insensitiveMatch(string $string): bool { return $this->equals($string, Config\Equals::CASE_INSENSITIVE); }
Determine if the string matches another string regardless of case. @param string $string The string to compare against
insensitiveMatch
php
PHLAK/Twine
src/Traits/Aliases.php
https://github.com/PHLAK/Twine/blob/master/src/Traits/Aliases.php
MIT