Skip to content

Commit e04614a

Browse files
committed
Fixed payload
1 parent 25067ab commit e04614a

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/PushbulletMessage.php

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,31 @@ public function url($url)
144144
public function toArray()
145145
{
146146
$payload = [
147-
'target' => $this->target->getTarget(),
148147
'type' => $this->type,
149148
'title' => $this->title,
150149
'body' => $this->message,
151150
];
152151

153-
if ($this->type === static::TYPE_LINK) {
154-
$payload['url'] = $this->url;
155-
}
152+
return array_merge(
153+
$payload,
154+
$this->target->getTarget(),
155+
$this->getUrlParameter()
156+
);
157+
}
158+
159+
/**
160+
* @return bool
161+
*/
162+
private function isLink()
163+
{
164+
return $this->type === static::TYPE_LINK;
165+
}
156166

157-
return $payload;
167+
/**
168+
* @return array
169+
*/
170+
private function getUrlParameter()
171+
{
172+
return $this->isLink() ? ['url' => $this->url] : [];
158173
}
159174
}

tests/PushbulletMessageTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
namespace NotificationChannels\Pushbullet\Test;
44

55
use NotificationChannels\Pushbullet\PushbulletMessage;
6+
use PHPUnit\Framework\TestCase;
67

7-
class PushbulletMessageTest extends \PHPUnit_Framework_TestCase
8+
class PushbulletMessageTest extends TestCase
89
{
910
/** @test */
1011
public function message_can_be_instantiated_with_text()

0 commit comments

Comments
 (0)