1 | <?php |
||
18 | trait SlackTrait |
||
19 | { |
||
20 | /** |
||
21 | * make text bold. |
||
22 | * |
||
23 | * @param $string |
||
24 | * |
||
25 | * @return string |
||
26 | */ |
||
27 | 23 | protected function bold($string) : string |
|
31 | |||
32 | /** |
||
33 | * make text italic. |
||
34 | * |
||
35 | * @param $string |
||
36 | * |
||
37 | * @return string |
||
38 | */ |
||
39 | 8 | protected function italic($string) : string |
|
43 | |||
44 | /** |
||
45 | * build a review line. |
||
46 | * |
||
47 | * @param \stdClass $item the review item |
||
48 | * |
||
49 | * @return string |
||
50 | */ |
||
51 | 3 | protected function buildReviewLine($item) : string |
|
52 | { |
||
53 | 3 | return $this->bold($item->subject) . ' <https://review.typo3.org/' . $item->_number |
|
54 | 3 | . '|Review #' . $item->_number . ' now>'; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * @param $item |
||
59 | * |
||
60 | * @return string |
||
61 | */ |
||
62 | 7 | protected function buildIssueMessage($item) : string |
|
63 | { |
||
64 | 7 | $created = substr($item->created_on, 0, 19); |
|
65 | 7 | $updated = substr($item->updated_on, 0, 19); |
|
66 | 7 | $text = $this->bold('[' . $item->tracker->name . '] ' . $item->subject) |
|
67 | 7 | . ' by ' . $this->italic($item->author->name) . chr(10); |
|
68 | 7 | $text .= 'Project: ' . $this->bold($item->project->name); |
|
69 | 7 | if (!empty($item->category->name)) { |
|
70 | 1 | $text .= ' | Category: ' . $this->bold($item->category->name); |
|
71 | } |
||
72 | 7 | $text .= ' | Status: ' . $this->bold($item->status->name) . chr(10); |
|
73 | 7 | $text .= ':calendar: Created: ' . $this->bold($created) . ' | Last update: ' . $this->bold($updated) . chr(10); |
|
74 | 7 | $text .= '<https://forge.typo3.org/issues/' . $item->id . '|:arrow_right: View on Forge>'; |
|
75 | |||
76 | 7 | return $text; |
|
77 | } |
||
78 | |||
79 | /** |
||
80 | * @param string $text |
||
81 | * @param string $channel |
||
82 | * |
||
83 | * @return array |
||
84 | */ |
||
85 | 5 | protected function getBaseDataArray(string $text, string $channel) : array |
|
95 | |||
96 | /** |
||
97 | * @param Attachment $attachment |
||
98 | * |
||
99 | * @return DataObject |
||
100 | */ |
||
101 | 4 | protected function buildAttachment(Attachment $attachment) : DataObject |
|
117 | } |
||
118 |