Skip to content

Commit

Permalink
added title and title_link attachment attributes to this awesome pack…
Browse files Browse the repository at this point in the history
…age. Next up is to make the tests pass
  • Loading branch information
mcampbell508 committed Jan 25, 2015
1 parent 21fcd62 commit 57aaf7a
Showing 1 changed file with 71 additions and 5 deletions.
76 changes: 71 additions & 5 deletions src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use InvalidArgumentException;

class Attachment {

/**
* The fallback text to use for clients that don't support attachments
*
Expand Down Expand Up @@ -32,6 +32,20 @@ class Attachment {
*/
protected $color = 'good';

/**
* The title to use for the attachment
*
* @var string
*/
protected $title = '';

/**
* The title_link to use for the attachment
*
* @var string
*/
protected $titleLink = '';

/**
* The fields of the attachment
*
Expand All @@ -49,6 +63,10 @@ public function __construct(array $attributes)
{
if (isset($attributes['fallback'])) $this->setFallback($attributes['fallback']);

if (isset($attributes['title'])) $this->setTitle($attributes['title']);

if (isset($attributes['title_link'])) $this->setTitleLink($attributes['title_link']);

if (isset($attributes['text'])) $this->setText($attributes['text']);

if (isset($attributes['pretext'])) $this->setPretext($attributes['pretext']);
Expand Down Expand Up @@ -150,6 +168,52 @@ public function setColor($color)
return $this;
}

/**
* Get the title to use for the attachment
*
* @return string
*/
public function getTitle()
{
return $this->title;
}

/**
* Set the title to use for the attachment
*
* @param string $title
* @return void
*/
public function setTitle($title)
{
$this->title = $title;

return $this;
}

/**
* Get the title to use for the attachment
*
* @return string
*/
public function getTitleLink()
{
return $this->titleLink;
}

/**
* Set the title_link to use for the attachment
*
* @param string $titleLink
* @return void
*/
public function setTitleLink($titleLink)
{
$this->titleLink = $titleLink;

return $this;
}

/**
* Get the fields for the attachment
*
Expand Down Expand Up @@ -223,10 +287,12 @@ public function clearFields()
public function toArray()
{
$data = [
'fallback' => $this->getFallback(),
'text' => $this->getText(),
'pretext' => $this->getPretext(),
'color' => $this->getColor()
'fallback' => $this->getFallback(),
'text' => $this->getText(),
'pretext' => $this->getPretext(),
'color' => $this->getColor(),
'title' => $this->getTitle(),
'title_link' => $this->getTitleLink()
];

$data['fields'] = $this->getFieldsAsArrays();
Expand Down

0 comments on commit 57aaf7a

Please sign in to comment.