forked from mcrumm/phlack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAttachment.php
109 lines (95 loc) · 2.23 KB
/
Attachment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
namespace Crummy\Phlack\Message;
use Crummy\Phlack\Common\OptionsResolver;
use Crummy\Phlack\Message\Collection\FieldCollection;
class Attachment extends Partial implements AttachmentInterface
{
protected $required = [ 'fallback' ];
protected $optional = [ 'text', 'pretext', 'color', 'fields' ];
/**
* {@inheritDoc}
*/
public function __construct($data = [])
{
if (!isset($data['fields'])) {
$data['fields'] = new FieldCollection();
}
parent::__construct($data);
}
/**
* {@inheritDoc}
*/
protected function setDefaultOptions(OptionsResolver $resolver)
{
parent::setDefaultOptions($resolver);
$resolver->setTypesAllowed([
'fields' => '\Crummy\Phlack\Message\Collection\FieldCollection'
]);
}
/**
* @param $fallback
* @return $this
* @deprecated Will be removed in 0.6.0
*/
public function setFallback($fallback)
{
$this['fallback'] = (string)$fallback;
return $this;
}
/**
* @param $text
* @return $this
* @deprecated Will be removed in 0.6.0
*/
public function setText($text)
{
$this['text'] = (string)$text;
return $this;
}
/**
* @param $pretext
* @return $this
* @deprecated Will be removed in 0.6.0
*/
public function setPretext($pretext)
{
$this['pretext'] = (string)$pretext;
return $this;
}
/**
* @param $color
* @return $this
* @deprecated Will be removed in 0.6.0
*/
public function setColor($color)
{
$this['color'] = (string)$color;
return $this;
}
/**
* @param FieldInterface $field
* @return $this
*/
public function addField(FieldInterface $field)
{
$this['fields']->add($field);
return $this;
}
/**
* @param FieldCollection $fields
* @return $this
* @deprecated Will be removed in 0.6.0
*/
public function setFields(FieldCollection $fields)
{
$this['fields'] = $fields;
return $this;
}
/**
* @return FieldCollection
*/
public function getFields()
{
return $this['fields'];
}
}