Fenos\Notifynder\Senders\SenderFactory::getSender PHP Method

getSender() public method

Get the right sender when the data is passed.
public getSender ( array $infoNotifications, $category = null ) : SendMultiple | SendOne
$infoNotifications array
$category
return SendMultiple | SendOne
    public function getSender($infoNotifications, $category = null)
    {
        if ($infoNotifications instanceof NotifynderBuilder) {
            $infoNotifications = $infoNotifications->toArray();
        }
        // if the array is multidimensional
        // it means that we want to send
        // multiple notifications
        if ($this->isMultiArray($infoNotifications)) {
            return $this->sendMultiple($infoNotifications);
        } else {
            return $this->sendSingle($infoNotifications, $category);
        }
    }

Usage Example

 /** @test */
 function it_send_now_a_notification(SenderFactory $senderFactory, DefaultSender $sender, StoreNotification $storeNotification)
 {
     $notifications = [];
     $category = 1;
     $senderFactory->getSender($notifications, $category)->shouldBeCalled()->willReturn($sender);
     $sender->send($storeNotification)->shouldBeCalled()->willReturn(1);
     $this->sendNow($notifications, $category)->shouldReturn(1);
 }
All Usage Examples Of Fenos\Notifynder\Senders\SenderFactory::getSender