Skip to content

Commit

Permalink
fix styleCI (#23)
Browse files Browse the repository at this point in the history
* wip

* wip

* wip

* wip
  • Loading branch information
ossycodes authored Mar 9, 2023
1 parent 20af583 commit 2b5a35d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
22 changes: 11 additions & 11 deletions src/AfricasTalkingChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace NotificationChannels\AfricasTalking;

use AfricasTalking\SDK\AfricasTalking as AfricasTalkingSDK;
use Exception;
use Illuminate\Notifications\Notification;
use AfricasTalking\SDK\AfricasTalking as AfricasTalkingSDK;
use NotificationChannels\AfricasTalking\Exceptions\InvalidPhonenumber;
use NotificationChannels\AfricasTalking\Exceptions\CouldNotSendNotification;
use NotificationChannels\AfricasTalking\Exceptions\InvalidPhonenumber;

class AfricasTalkingChannel
{
Expand All @@ -22,8 +22,9 @@ public function __construct(AfricasTalkingSDK $africasTalking)
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
*
* @throws CouldNotSendNotification
*/
public function send($notifiable, Notification $notification)
Expand All @@ -32,7 +33,7 @@ public function send($notifiable, Notification $notification)

$phoneNumber = $this->getTo($notifiable, $notification, $message);

if(empty($phoneNumber)) {
if (empty($phoneNumber)) {
throw InvalidPhonenumber::configurationNotSet();
}

Expand All @@ -43,10 +44,10 @@ public function send($notifiable, Notification $notification)
];
} else {
$params = [
'to' => $phoneNumber,
'message' => $message->getContent(),
'from' => $message->getSender(),
];
'to' => $phoneNumber,
'message' => $message->getContent(),
'from' => $message->getSender(),
];
}

try {
Expand All @@ -56,10 +57,9 @@ public function send($notifiable, Notification $notification)
}
}


private function getTo($notifiable, Notification $notification, AfricasTalkingMessage $message)
{
if(!empty($message->getTo())) {
if (! empty($message->getTo())) {
return $message->getTo();
}

Expand Down
10 changes: 5 additions & 5 deletions src/AfricasTalkingMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AfricasTalkingMessage
/**
* Set content for this message.
*
* @param string $content
* @return this
* @param string $content
* @return $this
*/
public function content(string $content): self
{
Expand All @@ -29,7 +29,7 @@ public function content(string $content): self
/**
* Set sender for this message.
*
* @param string $from
* @param string $from
* @return self
*/
public function from(string $from): self
Expand All @@ -39,10 +39,10 @@ public function from(string $from): self
return $this;
}

/**
/**
* Set recipient for this message.
*
* @param string $from
* @param string $from
* @return self
*/
public function to(string $to): self
Expand Down
7 changes: 3 additions & 4 deletions src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
class CouldNotSendNotification extends Exception
{
/**
* @param string $error
* @param string $error
* @return CouldNotSendNotification
*/
public static function serviceRespondedWithAnError(string $error): self
{
return new static("AfricasTalking service responded with an error: {$error}");
}


public static function invalidReceiver(): self
{
return new static("The notifiable did not have a receiving phone number. Add a routeNotificationForAfricasTalking
method or a phone_number attribute to your notifiable.");
return new static('The notifiable did not have a receiving phone number. Add a routeNotificationForAfricasTalking
method or a phone_number attribute to your notifiable.');
}
}
7 changes: 4 additions & 3 deletions tests/AfricasTalkingChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function it_can_send_sms_notification_to_anonymous_notifiable_using_class
->once()
->andReturn(200);

$this->channel->send((new AnonymousNotifiable())->route(AfricasTalkingChannel::class, "+1111111111"), new TestNotification);
$this->channel->send((new AnonymousNotifiable())->route(AfricasTalkingChannel::class, '+1111111111'), new TestNotification);
}

/** @test */
Expand All @@ -73,7 +73,7 @@ public function it_can_send_sms_notification_to_anonymous_notifiable_using_strin
->once()
->andReturn(200);

$this->channel->send((new AnonymousNotifiable())->route('africasTalking', "+1111111111"), new TestNotification);
$this->channel->send((new AnonymousNotifiable())->route('africasTalking', '+1111111111'), new TestNotification);
}

/** @test */
Expand Down Expand Up @@ -123,6 +123,7 @@ class TestNotification extends Notification
/**
* @param $notifiable
* @return AfricasTalkingMessage
*
* @throws CouldNotSendNotification
*/
public function toAfricasTalking($notifiable)
Expand All @@ -136,6 +137,7 @@ class TestNotificationWithGetTo extends Notification
/**
* @param $notifiable
* @return AfricasTalkingMessage
*
* @throws CouldNotSendNotification
*/
public function toAfricasTalking($notifiable)
Expand All @@ -145,7 +147,6 @@ public function toAfricasTalking($notifiable)
}
}


class Notifiable
{
public $phone_number = null;
Expand Down

0 comments on commit 2b5a35d

Please sign in to comment.