Skip to content

Commit

Permalink
fix phpdoc issues and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
seyfer committed Aug 9, 2017
1 parent 07b8fe2 commit f3e8495
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .atoum.bootstrap.php
@@ -1,3 +1,3 @@
<?php

require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
4 changes: 2 additions & 2 deletions .atoum.php
@@ -1,6 +1,6 @@
<?php

$runner->addTestsFromDirectory(__DIR__.'/tests/units');
$runner->addTestsFromDirectory(__DIR__ . '/tests/units');

$script->noCodeCoverageForNamespaces('mageekguy', 'Symfony');
$script->bootstrapFile(__DIR__.DIRECTORY_SEPARATOR.'.atoum.bootstrap.php');
$script->bootstrapFile(__DIR__ . DIRECTORY_SEPARATOR . '.atoum.bootstrap.php');
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -35,7 +35,8 @@
"doctrine/inflector": "~1.0"
},
"require-dev": {
"atoum/atoum": "dev-master"
"atoum/atoum": "^3.1",
"atoum/stubs": "^2.5"
},
"config": {
"bin-dir": "bin"
Expand Down
4 changes: 2 additions & 2 deletions np
@@ -1,10 +1,10 @@
#!/usr/bin/env php
<?php

if (file_exists($a = __DIR__.'/../../autoload.php')) {
if (file_exists($a = __DIR__ . '/../../autoload.php')) {
require_once $a;
} else {
require_once __DIR__.'/vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';
}

use Sly\NotificationPusher\Console\Application;
Expand Down
36 changes: 19 additions & 17 deletions src/Sly/NotificationPusher/Adapter/Apns.php
Expand Up @@ -11,19 +11,18 @@

namespace Sly\NotificationPusher\Adapter;

use Sly\NotificationPusher\Model\BaseOptionedModel;
use Sly\NotificationPusher\Model\PushInterface;
use Sly\NotificationPusher\Model\DeviceInterface;
use Sly\NotificationPusher\Collection\DeviceCollection;
use Sly\NotificationPusher\Exception\AdapterException;
use Sly\NotificationPusher\Exception\PushException;
use Sly\NotificationPusher\Collection\DeviceCollection;

use Sly\NotificationPusher\Model\BaseOptionedModel;
use Sly\NotificationPusher\Model\DeviceInterface;
use Sly\NotificationPusher\Model\PushInterface;
use ZendService\Apple\Apns\Client\AbstractClient as ServiceAbstractClient;
use ZendService\Apple\Apns\Client\Feedback as ServiceFeedbackClient;
use ZendService\Apple\Apns\Client\Message as ServiceClient;
use ZendService\Apple\Apns\Message as ServiceMessage;
use ZendService\Apple\Apns\Message\Alert as ServiceAlert;
use ZendService\Apple\Apns\Response\Message as ServiceResponse;
use ZendService\Apple\Apns\Client\Feedback as ServiceFeedbackClient;

/**
* APNS adapter.
Expand All @@ -35,10 +34,14 @@
class Apns extends BaseAdapter
{

/** @var ServiceClient */
/**
* @var ServiceClient
*/
private $openedClient;

/** @var ServiceFeedbackClient */
/**
* @var ServiceFeedbackClient
*/
private $feedbackClient;

/**
Expand Down Expand Up @@ -161,15 +164,14 @@ private function getOpenedFeedbackClient()
public function getServiceMessageFromOrigin(DeviceInterface $device, BaseOptionedModel $message)
{
$badge = ($message->hasOption('badge'))
? (int) ($message->getOption('badge') + $device->getParameter('badge', 0))
: false
;
? (int)($message->getOption('badge') + $device->getParameter('badge', 0))
: false;

$sound = $message->getOption('sound');
$sound = $message->getOption('sound');
$contentAvailable = $message->getOption('content-available');
$category = $message->getOption('category');
$urlArgs = $message->getOption('urlArgs');
$expire = $message->getOption('expire');
$category = $message->getOption('category');
$urlArgs = $message->getOption('urlArgs');
$expire = $message->getOption('expire');

$alert = new ServiceAlert(
$message->getText(),
Expand Down Expand Up @@ -204,7 +206,7 @@ public function getServiceMessageFromOrigin(DeviceInterface $device, BaseOptione
}

$serviceMessage = new ServiceMessage();
$serviceMessage->setId(sha1($device->getToken().$message->getText()));
$serviceMessage->setId(sha1($device->getToken() . $message->getText()));
$serviceMessage->setAlert($alert);
$serviceMessage->setToken($device->getToken());
if (false !== $badge) {
Expand All @@ -224,7 +226,7 @@ public function getServiceMessageFromOrigin(DeviceInterface $device, BaseOptione
$serviceMessage->setCategory($category);
}

if( null !== $urlArgs) {
if (null !== $urlArgs) {
$serviceMessage->setUrlArgs($urlArgs);
}

Expand Down
3 changes: 1 addition & 2 deletions src/Sly/NotificationPusher/Adapter/BaseAdapter.php
Expand Up @@ -11,10 +11,9 @@

namespace Sly\NotificationPusher\Adapter;

use Symfony\Component\OptionsResolver\OptionsResolver;

use Sly\NotificationPusher\Model\BaseParameteredModel;
use Sly\NotificationPusher\PushManager;
use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* BaseAdapter.
Expand Down
19 changes: 8 additions & 11 deletions src/Sly/NotificationPusher/Adapter/Gcm.php
Expand Up @@ -11,19 +11,16 @@

namespace Sly\NotificationPusher\Adapter;

use Sly\NotificationPusher\Model\BaseOptionedModel;
use Sly\NotificationPusher\Model\PushInterface;
use InvalidArgumentException;
use Sly\NotificationPusher\Collection\DeviceCollection;
use Sly\NotificationPusher\Exception\PushException;

use Sly\NotificationPusher\Model\BaseOptionedModel;
use Sly\NotificationPusher\Model\PushInterface;
use Zend\Http\Client as HttpClient;
use Zend\Http\Client\Adapter\Socket as HttpSocketAdapter;

use ZendService\Google\Exception\RuntimeException as ServiceRuntimeException;
use ZendService\Google\Gcm\Client as ServiceClient;
use ZendService\Google\Gcm\Message as ServiceMessage;
use ZendService\Google\Exception\RuntimeException as ServiceRuntimeException;

use InvalidArgumentException;

/**
* GCM adapter.
Expand Down Expand Up @@ -68,7 +65,7 @@ public function push(PushInterface $push)

try {

$response = $client->send($message);
$response = $client->send($message);
$responseResults = $response->getResults();

foreach ($tokensRange as $token) {
Expand Down Expand Up @@ -115,8 +112,8 @@ public function getOpenedClient()
$newClient = new \Zend\Http\Client(
null,
[
'adapter' => 'Zend\Http\Client\Adapter\Socket',
'sslverifypeer' => false
'adapter' => 'Zend\Http\Client\Adapter\Socket',
'sslverifypeer' => false,
]
);

Expand Down Expand Up @@ -161,7 +158,7 @@ public function getDefinedParameters()
'delayWhileIdle',
'ttl',
'restrictedPackageName',
'dryRun'
'dryRun',
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sly/NotificationPusher/Collection/ResponseCollection.php
Expand Up @@ -39,8 +39,8 @@ public function getIterator()
}

/**
* @param string $token
* @param mixed $response
* @param string $token
* @param mixed $response
*/
public function add($token, $response)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sly/NotificationPusher/Console/Application.php
Expand Up @@ -11,9 +11,9 @@

namespace Sly\NotificationPusher\Console;

use Symfony\Component\Console\Application as BaseApplication;
use Sly\NotificationPusher\NotificationPusher;
use Sly\NotificationPusher\Console\Command\PushCommand;
use Sly\NotificationPusher\NotificationPusher;
use Symfony\Component\Console\Application as BaseApplication;

/**
* Application.
Expand Down
16 changes: 7 additions & 9 deletions src/Sly/NotificationPusher/Console/Command/PushCommand.php
Expand Up @@ -11,20 +11,18 @@

namespace Sly\NotificationPusher\Console\Command;

use Doctrine\Common\Inflector\Inflector;
use Sly\NotificationPusher\Exception\AdapterException;
use Sly\NotificationPusher\Model\Device;
use Sly\NotificationPusher\Model\Message;
use Sly\NotificationPusher\Model\Push;
use Sly\NotificationPusher\PushManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use Sly\NotificationPusher\PushManager;
use Sly\NotificationPusher\Model\Device;
use Sly\NotificationPusher\Model\Message;
use Sly\NotificationPusher\Model\Push;
use Sly\NotificationPusher\Exception\AdapterException;

use Doctrine\Common\Inflector\Inflector;

/**
* PushCommand.
*
Expand Down Expand Up @@ -108,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
private function getAdapterClassFromArgument($argument)
{
if (!class_exists($adapterClass = $argument) &&
!class_exists($adapterClass = '\\Sly\\NotificationPusher\\Adapter\\'.ucfirst($argument))) {
!class_exists($adapterClass = '\\Sly\\NotificationPusher\\Adapter\\' . ucfirst($argument))) {
throw new AdapterException(
sprintf(
'Adapter class %s does not exist',
Expand Down
8 changes: 4 additions & 4 deletions src/Sly/NotificationPusher/Model/BaseOptionedModel.php
Expand Up @@ -48,8 +48,8 @@ public function hasOption($key)
/**
* Get option.
*
* @param string $key Key
* @param mixed $default Default
* @param string $key Key
* @param mixed $default Default
*
* @return mixed
*/
Expand All @@ -75,8 +75,8 @@ public function setOptions($options)
/**
* Set option.
*
* @param string $key Key
* @param mixed $value Value
* @param string $key Key
* @param mixed $value Value
*
* @return mixed
*/
Expand Down
8 changes: 4 additions & 4 deletions src/Sly/NotificationPusher/Model/BaseParameteredModel.php
Expand Up @@ -48,8 +48,8 @@ public function hasParameter($key)
/**
* Get parameter.
*
* @param string $key Key
* @param mixed $default Default
* @param string $key Key
* @param mixed $default Default
*
* @return mixed
*/
Expand All @@ -75,8 +75,8 @@ public function setParameters($parameters)
/**
* Set parameter.
*
* @param string $key Key
* @param mixed $value Value
* @param string $key Key
* @param mixed $value Value
*
* @return mixed
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Sly/NotificationPusher/Model/Device.php
Expand Up @@ -26,8 +26,8 @@ class Device extends BaseParameteredModel implements DeviceInterface
/**
* Constructor.
*
* @param string $token Token
* @param array $parameters Parameters
* @param string $token Token
* @param array $parameters Parameters
*/
public function __construct($token, array $parameters = [])
{
Expand Down
4 changes: 2 additions & 2 deletions src/Sly/NotificationPusher/Model/Message.php
Expand Up @@ -26,8 +26,8 @@ class Message extends BaseOptionedModel implements MessageInterface
/**
* Constructor.
*
* @param string $text Text
* @param array $options Options
* @param string $text Text
* @param array $options Options
*/
public function __construct($text, array $options = [])
{
Expand Down
23 changes: 12 additions & 11 deletions src/Sly/NotificationPusher/Model/Push.php
Expand Up @@ -11,9 +11,9 @@

namespace Sly\NotificationPusher\Model;

use Sly\NotificationPusher\Adapter\AdapterInterface;
use Sly\NotificationPusher\Collection\DeviceCollection;
use Sly\NotificationPusher\Collection\ResponseCollection;
use Sly\NotificationPusher\Adapter\AdapterInterface;
use Sly\NotificationPusher\Exception\AdapterException;

/**
Expand Down Expand Up @@ -58,9 +58,9 @@ class Push extends BaseOptionedModel implements PushInterface
* Constructor.
*
* @param \Sly\NotificationPusher\Adapter\AdapterInterface $adapter Adapter
* @param DeviceInterface|DeviceCollection $devices Device(s)
* @param \Sly\NotificationPusher\Model\MessageInterface $message Message
* @param array $options Options
* @param DeviceInterface|DeviceCollection $devices Device(s)
* @param \Sly\NotificationPusher\Model\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.
Expand Down Expand Up @@ -95,7 +95,7 @@ private function checkDevicesTokens()
throw new AdapterException(
sprintf(
'Adapter %s does not support %s token\'s device',
(string) $adapter,
(string)$adapter,
$device->getToken()
)
);
Expand Down Expand Up @@ -134,7 +134,7 @@ public function setStatus($status)
*/
public function isPushed()
{
return (bool) (self::STATUS_PUSHED === $this->status);
return (bool)(self::STATUS_PUSHED === $this->status);
}

/**
Expand Down Expand Up @@ -224,12 +224,12 @@ public function setDevices(DeviceCollection $devices)
return $this;
}


/**
* Get Responses
* @return Sly\NotificationPusher\Collection\ResponseCollection
* @return \Sly\NotificationPusher\Collection\ResponseCollection
*/
public function getResponses() {
public function getResponses()
{
if (!$this->responses)
$this->responses = new ResponseCollection();

Expand All @@ -238,10 +238,11 @@ public function getResponses() {

/**
* adds a response
* @param Sly\NotificationPusher\Model\Device $device
* @param \Sly\NotificationPusher\Model\Device $device
* @param mixed $response
*/
public function addResponse(Device $device, $response) {
public function addResponse(Device $device, $response)
{
$this->getResponses()->add($device->getToken(), $response);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Sly/NotificationPusher/Model/PushInterface.php
Expand Up @@ -106,13 +106,13 @@ public function setDevices(DeviceCollection $devices);

/**
* Get Responses
* @return Sly\NotificationPusher\Collection\ResponseCollection
* @return \Sly\NotificationPusher\Collection\ResponseCollection
*/
public function getResponses();

/**
* adds a response
* @param Sly\NotificationPusher\Model\Device $device
* @param \Sly\NotificationPusher\Model\Device $device
* @param mixed $response
*/
public function addResponse(Device $device, $response);
Expand Down

0 comments on commit f3e8495

Please sign in to comment.