updated-packages
This commit is contained in:
@@ -12,8 +12,6 @@
|
||||
namespace Sly\NotificationPusher\Model;
|
||||
|
||||
/**
|
||||
* BaseOptionedModel.
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
abstract class BaseOptionedModel
|
||||
@@ -24,8 +22,6 @@ abstract class BaseOptionedModel
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Get options.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions()
|
||||
@@ -34,8 +30,6 @@ abstract class BaseOptionedModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Has option.
|
||||
*
|
||||
* @param string $key Key
|
||||
*
|
||||
* @return boolean
|
||||
@@ -46,8 +40,6 @@ abstract class BaseOptionedModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Get option.
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param mixed $default Default
|
||||
*
|
||||
@@ -59,11 +51,9 @@ abstract class BaseOptionedModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options.
|
||||
*
|
||||
* @param array $options Options
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\BaseOptionedModel
|
||||
* @return BaseOptionedModel
|
||||
*/
|
||||
public function setOptions($options)
|
||||
{
|
||||
@@ -73,8 +63,6 @@ abstract class BaseOptionedModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Set option.
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param mixed $value Value
|
||||
*
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
namespace Sly\NotificationPusher\Model;
|
||||
|
||||
/**
|
||||
* BaseParameteredModel.
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
abstract class BaseParameteredModel
|
||||
@@ -24,8 +22,6 @@ abstract class BaseParameteredModel
|
||||
protected $parameters = [];
|
||||
|
||||
/**
|
||||
* Get parameters.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getParameters()
|
||||
@@ -34,8 +30,6 @@ abstract class BaseParameteredModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Has parameter.
|
||||
*
|
||||
* @param string $key Key
|
||||
*
|
||||
* @return boolean
|
||||
@@ -46,8 +40,6 @@ abstract class BaseParameteredModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Get parameter.
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param mixed $default Default
|
||||
*
|
||||
@@ -59,11 +51,9 @@ abstract class BaseParameteredModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameters.
|
||||
*
|
||||
* @param array $parameters Parameters
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\BaseParameteredModel
|
||||
* @return BaseParameteredModel
|
||||
*/
|
||||
public function setParameters($parameters)
|
||||
{
|
||||
@@ -73,8 +63,6 @@ abstract class BaseParameteredModel
|
||||
}
|
||||
|
||||
/**
|
||||
* Set parameter.
|
||||
*
|
||||
* @param string $key Key
|
||||
* @param mixed $value Value
|
||||
*
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
namespace Sly\NotificationPusher\Model;
|
||||
|
||||
/**
|
||||
* Device.
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class Device extends BaseParameteredModel implements DeviceInterface
|
||||
@@ -24,20 +22,16 @@ class Device extends BaseParameteredModel implements DeviceInterface
|
||||
private $token;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $token Token
|
||||
* @param array $parameters Parameters
|
||||
*/
|
||||
public function __construct($token, array $parameters = [])
|
||||
{
|
||||
$this->token = $token;
|
||||
$this->token = $token;
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToken()
|
||||
@@ -46,11 +40,9 @@ class Device extends BaseParameteredModel implements DeviceInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set token.
|
||||
*
|
||||
* @param string $token Token
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\DeviceInterface
|
||||
* @return DeviceInterface
|
||||
*/
|
||||
public function setToken($token)
|
||||
{
|
||||
|
||||
@@ -12,25 +12,19 @@
|
||||
namespace Sly\NotificationPusher\Model;
|
||||
|
||||
/**
|
||||
* DeviceInterface
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
interface DeviceInterface
|
||||
{
|
||||
/**
|
||||
* Get token.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToken();
|
||||
|
||||
/**
|
||||
* Set token.
|
||||
*
|
||||
* @param string $token Token
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\DeviceInterface
|
||||
* @return DeviceInterface
|
||||
*/
|
||||
public function setToken($token);
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
namespace Sly\NotificationPusher\Model;
|
||||
|
||||
/**
|
||||
* Message.
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class Message extends BaseOptionedModel implements MessageInterface
|
||||
@@ -24,20 +22,16 @@ class Message extends BaseOptionedModel implements MessageInterface
|
||||
protected $text;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $text Text
|
||||
* @param array $options Options
|
||||
*/
|
||||
public function __construct($text, array $options = [])
|
||||
{
|
||||
$this->text = $text;
|
||||
$this->text = $text;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText()
|
||||
@@ -46,11 +40,9 @@ class Message extends BaseOptionedModel implements MessageInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Text.
|
||||
*
|
||||
* @param string $text Text
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\MessageInterface
|
||||
* @return MessageInterface
|
||||
*/
|
||||
public function setText($text)
|
||||
{
|
||||
|
||||
@@ -12,25 +12,19 @@
|
||||
namespace Sly\NotificationPusher\Model;
|
||||
|
||||
/**
|
||||
* MessageInterface
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
interface MessageInterface
|
||||
{
|
||||
/**
|
||||
* Get Text.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getText();
|
||||
|
||||
/**
|
||||
* Set Text.
|
||||
*
|
||||
* @param string $text Text
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\MessageInterface
|
||||
* @return MessageInterface
|
||||
*/
|
||||
public function setText($text);
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ use Sly\NotificationPusher\Collection\ResponseCollection;
|
||||
use Sly\NotificationPusher\Exception\AdapterException;
|
||||
|
||||
/**
|
||||
* Push.
|
||||
*
|
||||
* @author Cédric Dugat <cedric@dugat.me>
|
||||
*/
|
||||
class Push extends BaseOptionedModel implements PushInterface
|
||||
@@ -30,17 +28,17 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var \Sly\NotificationPusher\Adapter\AdapterInterface
|
||||
* @var AdapterInterface
|
||||
*/
|
||||
private $adapter;
|
||||
|
||||
/**
|
||||
* @var \Sly\NotificationPusher\Model\MessageInterface
|
||||
* @var MessageInterface
|
||||
*/
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* @var \Sly\NotificationPusher\Collection\DeviceCollection
|
||||
* @var DeviceCollection
|
||||
*/
|
||||
private $devices;
|
||||
|
||||
@@ -50,22 +48,20 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
private $pushedAt;
|
||||
|
||||
/**
|
||||
* @var \Sly\NotificationPusher\Collection\ResponseCollection
|
||||
* @var ResponseCollection
|
||||
*/
|
||||
private $responses;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param \Sly\NotificationPusher\Adapter\AdapterInterface $adapter Adapter
|
||||
* @param AdapterInterface $adapter Adapter
|
||||
* @param DeviceInterface|DeviceCollection $devices Device(s)
|
||||
* @param \Sly\NotificationPusher\Model\MessageInterface $message Message
|
||||
* @param MessageInterface $message Message
|
||||
* @param array $options Options
|
||||
*
|
||||
* Options are adapters specific ones, like Apns "badge" or "sound" option for example.
|
||||
* Of course, they can be more general.
|
||||
*
|
||||
* @throws \Sly\NotificationPusher\Exception\AdapterException
|
||||
* @throws AdapterException
|
||||
*/
|
||||
public function __construct(AdapterInterface $adapter, $devices, MessageInterface $message, array $options = [])
|
||||
{
|
||||
@@ -77,14 +73,13 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
$this->devices = $devices;
|
||||
$this->message = $message;
|
||||
$this->options = $options;
|
||||
$this->status = self::STATUS_PENDING;
|
||||
$this->status = self::STATUS_PENDING;
|
||||
|
||||
$this->checkDevicesTokens();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check devices tokens.
|
||||
* @throws \Sly\NotificationPusher\Exception\AdapterException
|
||||
* @throws AdapterException
|
||||
*/
|
||||
private function checkDevicesTokens()
|
||||
{
|
||||
@@ -96,7 +91,7 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
throw new AdapterException(
|
||||
sprintf(
|
||||
'Adapter %s does not support %s token\'s device',
|
||||
(string)$adapter,
|
||||
(string) $adapter,
|
||||
$device->getToken()
|
||||
)
|
||||
);
|
||||
@@ -105,8 +100,6 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus()
|
||||
@@ -115,11 +108,9 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Status.
|
||||
*
|
||||
* @param string $status Status
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\PushInterface
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
@@ -129,32 +120,26 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* isPushed.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPushed()
|
||||
{
|
||||
return (bool)(self::STATUS_PUSHED === $this->status);
|
||||
return (bool) (self::STATUS_PUSHED === $this->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare as pushed.
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\PushInterface
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function pushed()
|
||||
{
|
||||
$this->status = self::STATUS_PUSHED;
|
||||
$this->status = self::STATUS_PUSHED;
|
||||
$this->pushedAt = new \DateTime();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Adapter.
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Adapter\AdapterInterface
|
||||
* @return AdapterInterface
|
||||
*/
|
||||
public function getAdapter()
|
||||
{
|
||||
@@ -162,11 +147,9 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Adapter.
|
||||
* @param AdapterInterface $adapter Adapter
|
||||
*
|
||||
* @param \Sly\NotificationPusher\Adapter\AdapterInterface $adapter Adapter
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\PushInterface
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function setAdapter(AdapterInterface $adapter)
|
||||
{
|
||||
@@ -176,9 +159,7 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Message.
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\MessageInterface
|
||||
* @return MessageInterface
|
||||
*/
|
||||
public function getMessage()
|
||||
{
|
||||
@@ -186,11 +167,9 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Message.
|
||||
* @param MessageInterface $message Message
|
||||
*
|
||||
* @param \Sly\NotificationPusher\Model\MessageInterface $message Message
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\PushInterface
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function setMessage(MessageInterface $message)
|
||||
{
|
||||
@@ -200,9 +179,7 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Devices.
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Collection\DeviceCollection
|
||||
* @return DeviceCollection
|
||||
*/
|
||||
public function getDevices()
|
||||
{
|
||||
@@ -210,11 +187,9 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Devices.
|
||||
* @param DeviceCollection $devices Devices
|
||||
*
|
||||
* @param \Sly\NotificationPusher\Collection\DeviceCollection $devices Devices
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\PushInterface
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function setDevices(DeviceCollection $devices)
|
||||
{
|
||||
@@ -226,8 +201,7 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Responses
|
||||
* @return \Sly\NotificationPusher\Collection\ResponseCollection
|
||||
* @return ResponseCollection
|
||||
*/
|
||||
public function getResponses()
|
||||
{
|
||||
@@ -238,8 +212,7 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a response
|
||||
* @param \Sly\NotificationPusher\Model\DeviceInterface $device
|
||||
* @param DeviceInterface $device
|
||||
* @param mixed $response
|
||||
*/
|
||||
public function addResponse(DeviceInterface $device, $response)
|
||||
@@ -248,8 +221,6 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get PushedAt.
|
||||
*
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getPushedAt()
|
||||
@@ -258,11 +229,9 @@ class Push extends BaseOptionedModel implements PushInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Set PushedAt.
|
||||
*
|
||||
* @param \DateTime $pushedAt PushedAt
|
||||
*
|
||||
* @return \Sly\NotificationPusher\Model\PushInterface
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function setPushedAt(\DateTime $pushedAt)
|
||||
{
|
||||
|
||||
@@ -14,28 +14,22 @@ namespace Sly\NotificationPusher\Model;
|
||||
use DateTime;
|
||||
use Sly\NotificationPusher\Adapter\AdapterInterface;
|
||||
use Sly\NotificationPusher\Collection\DeviceCollection;
|
||||
use Sly\NotificationPusher\Collection\ResponseCollection;
|
||||
|
||||
/**
|
||||
* PushInterface
|
||||
*/
|
||||
interface PushInterface
|
||||
{
|
||||
/**
|
||||
* Constants define available statuses
|
||||
*/
|
||||
const STATUS_PENDING = 'pending';
|
||||
const STATUS_PUSHED = 'sent';
|
||||
const STATUS_PUSHED = 'sent';
|
||||
|
||||
/**
|
||||
* Get Status.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus();
|
||||
|
||||
/**
|
||||
* Set Status.
|
||||
*
|
||||
* @param string $status Status
|
||||
*
|
||||
* @return PushInterface
|
||||
@@ -43,29 +37,21 @@ interface PushInterface
|
||||
public function setStatus($status);
|
||||
|
||||
/**
|
||||
* isPushed.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function isPushed();
|
||||
|
||||
/**
|
||||
* Declare as pushed.
|
||||
*
|
||||
* @return PushInterface
|
||||
*/
|
||||
public function pushed();
|
||||
|
||||
/**
|
||||
* Get Adapter.
|
||||
*
|
||||
* @return AdapterInterface
|
||||
*/
|
||||
public function getAdapter();
|
||||
|
||||
/**
|
||||
* Set Adapter.
|
||||
*
|
||||
* @param AdapterInterface $adapter Adapter
|
||||
*
|
||||
* @return PushInterface
|
||||
@@ -73,15 +59,11 @@ interface PushInterface
|
||||
public function setAdapter(AdapterInterface $adapter);
|
||||
|
||||
/**
|
||||
* Get Message.
|
||||
*
|
||||
* @return MessageInterface
|
||||
*/
|
||||
public function getMessage();
|
||||
|
||||
/**
|
||||
* Set Message.
|
||||
*
|
||||
* @param MessageInterface $message Message
|
||||
*
|
||||
* @return PushInterface
|
||||
@@ -89,15 +71,11 @@ interface PushInterface
|
||||
public function setMessage(MessageInterface $message);
|
||||
|
||||
/**
|
||||
* Get Devices.
|
||||
*
|
||||
* @return DeviceCollection
|
||||
*/
|
||||
public function getDevices();
|
||||
|
||||
/**
|
||||
* Set Devices.
|
||||
*
|
||||
* @param DeviceCollection $devices Devices
|
||||
*
|
||||
* @return PushInterface
|
||||
@@ -105,28 +83,22 @@ interface PushInterface
|
||||
public function setDevices(DeviceCollection $devices);
|
||||
|
||||
/**
|
||||
* Get Responses
|
||||
* @return \Sly\NotificationPusher\Collection\ResponseCollection
|
||||
* @return ResponseCollection
|
||||
*/
|
||||
public function getResponses();
|
||||
|
||||
/**
|
||||
* adds a response
|
||||
* @param \Sly\NotificationPusher\Model\DeviceInterface $device
|
||||
* @param DeviceInterface $device
|
||||
* @param mixed $response
|
||||
*/
|
||||
public function addResponse(DeviceInterface $device, $response);
|
||||
|
||||
/**
|
||||
* Get PushedAt.
|
||||
*
|
||||
* @return DateTime
|
||||
*/
|
||||
public function getPushedAt();
|
||||
|
||||
/**
|
||||
* Set PushedAt.
|
||||
*
|
||||
* @param DateTime $pushedAt PushedAt
|
||||
*
|
||||
* @return PushInterface
|
||||
|
||||
@@ -11,6 +11,9 @@ namespace Sly\NotificationPusher\Model;
|
||||
|
||||
use Sly\NotificationPusher\Collection\PushCollection;
|
||||
|
||||
/**
|
||||
* @author Oleg Abrazhaev <seyferseed@gmail.com>
|
||||
*/
|
||||
class Response implements ResponseInterface
|
||||
{
|
||||
/**
|
||||
@@ -28,9 +31,6 @@ class Response implements ResponseInterface
|
||||
*/
|
||||
private $pushCollection;
|
||||
|
||||
/**
|
||||
* Response constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->pushCollection = new PushCollection();
|
||||
@@ -59,7 +59,7 @@ class Response implements ResponseInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Sly\NotificationPusher\Model\PushInterface $push Push
|
||||
* @param PushInterface $push Push
|
||||
*/
|
||||
public function addPush(PushInterface $push)
|
||||
{
|
||||
@@ -89,4 +89,4 @@ class Response implements ResponseInterface
|
||||
{
|
||||
return $this->pushCollection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ namespace Sly\NotificationPusher\Model;
|
||||
|
||||
use Sly\NotificationPusher\Collection\PushCollection;
|
||||
|
||||
/**
|
||||
* @author Oleg Abrazhaev <seyferseed@gmail.com>
|
||||
*/
|
||||
interface ResponseInterface
|
||||
{
|
||||
/**
|
||||
@@ -25,7 +28,7 @@ interface ResponseInterface
|
||||
public function addOriginalResponse(DeviceInterface $device, $originalResponse);
|
||||
|
||||
/**
|
||||
* @param \Sly\NotificationPusher\Model\PushInterface $push Push
|
||||
* @param PushInterface $push Push
|
||||
*/
|
||||
public function addPush(PushInterface $push);
|
||||
|
||||
@@ -43,4 +46,4 @@ interface ResponseInterface
|
||||
* @return PushCollection
|
||||
*/
|
||||
public function getPushCollection();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user