Skip to content
This repository has been archived by the owner on Dec 7, 2019. It is now read-only.

Upgrade php version #27

Closed
wants to merge 17 commits into from
Closed
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- hhvm

before_install:
- cp tests/TestConfiguration.php.travis tests/TestConfiguration.php
- composer install --dev
- composer install

script:
- phpunit -c tests/phpunit.xml.dist
- ./vendor/bin/phpunit

notifications:
irc: "irc.freenode.org#zftalk.2"
24 changes: 11 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,24 @@
"notification",
"google"
],
"homepage": "http://packages.zendframework.com/",
"homepage": "https://github.com/zendframework/zendservice-google-gcm",
"license": "BSD-3-Clause",
"autoload": {
"psr-0": {
"ZendService\\Google\\Gcm\\": "library/",
"ZendService\\Google\\Exception\\": "library/"
"psr-4": {
"ZendService\\Google\\": "library/"
}
},
"repositories": [
{
"type": "composer",
"url": "http://packages.zendframework.com/"
"autoload-dev": {
"psr-4": {
"ZendServiceTest\\Google\\": "tests/"
}
],
},
"require": {
"php": ">=5.3.3",
"zendframework/zend-http": ">=2.0.0",
"zendframework/zend-json": ">=2.0.0"
"php": "^5.5 || ^7.0",
"zendframework/zend-http": "^2.0",
"zendframework/zend-json": "^2.0"
},
"require-dev": {
"phpunit/PHPUnit": "3.7.*"
"phpunit/PHPUnit": "^4.8"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Client
const SERVER_URI = 'https://gcm-http.googleapis.com/gcm/send';

/**
* @var Zend\Http\Client
* @var \Zend\Http\Client
*/
protected $httpClient;

Expand All @@ -56,7 +56,7 @@ public function getApiKey()
*
* @param string $apiKey
* @return Client
* @throws InvalidArgumentException
* @throws Exception\InvalidArgumentException
*/
public function setApiKey($apiKey)
{
Expand All @@ -70,21 +70,23 @@ public function setApiKey($apiKey)
/**
* Get HTTP Client
*
* @return Zend\Http\Client
* @throws \Zend\Http\Client\Exception\InvalidArgumentException
*
* @return \Zend\Http\Client
*/
public function getHttpClient()
{
if (!$this->httpClient) {
$this->httpClient = new HttpClient();
$this->httpClient->setOptions(array('strictredirects' => true));
$this->httpClient->setOptions(['strictredirects' => true]);
}
return $this->httpClient;
}

/**
* Set HTTP Client
*
* @param Zend\Http\Client
* @param \Zend\Http\Client
* @return Client
*/
public function setHttpClient(HttpClient $http)
Expand All @@ -96,9 +98,17 @@ public function setHttpClient(HttpClient $http)
/**
* Send Message
*
* @param Mesage $message
* @param Message $message
*
* @throws \Zend\Json\Exception\RuntimeException
* @throws \ZendService\Google\Exception\RuntimeException
* @throws \Zend\Http\Exception\RuntimeException
* @throws \Zend\Http\Client\Exception\RuntimeException
* @throws \Zend\Http\Exception\InvalidArgumentException
* @throws \Zend\Http\Client\Exception\InvalidArgumentException
* @throws \ZendService\Google\Exception\InvalidArgumentException
*
* @return Response
* @throws Exception\RuntimeException
*/
public function send(Message $message)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Message
/**
* @var array
*/
protected $registrationIds = array();
protected $registrationIds = [];

/**
* @var string
Expand All @@ -38,7 +38,7 @@ class Message
/**
* @var array
*/
protected $data = array();
protected $data = [];

/**
* @var bool
Expand All @@ -64,6 +64,9 @@ class Message
* Set Registration Ids
*
* @param array $ids
*
* @throws \ZendService\Google\Exception\InvalidArgumentException
*
* @return Message
*/
public function setRegistrationIds(array $ids)
Expand Down Expand Up @@ -110,7 +113,7 @@ public function addRegistrationId($id)
*/
public function clearRegistrationIds()
{
$this->registrationIds = array();
$this->registrationIds = [];
return $this;
}

Expand All @@ -133,7 +136,7 @@ public function getCollapseKey()
*/
public function setCollapseKey($key)
{
if (!is_null($key) && !(is_string($key) && strlen($key) > 0)) {
if (null !== $key && !(is_string($key) && strlen($key) > 0)) {
throw new Exception\InvalidArgumentException('$key must be null or a non-empty string');
}
$this->collapseKey = $key;
Expand All @@ -144,6 +147,9 @@ public function setCollapseKey($key)
* Set Data
*
* @param array $data
*
* @throws \ZendService\Google\Exception\InvalidArgumentException
*
* @return Message
*/
public function setData(array $data)
Expand All @@ -170,9 +176,11 @@ public function getData()
*
* @param string $key
* @param mixed $value
* @return Message
* @throws Exception\InvalidArgumentException
*
* @throws Exception\RuntimeException
* @throws Exception\InvalidArgumentException
*
* @return Message
*/
public function addData($key, $value)
{
Expand All @@ -193,7 +201,7 @@ public function addData($key, $value)
*/
public function clearData()
{
$this->data = array();
$this->data = [];
return $this;
}

Expand Down Expand Up @@ -250,7 +258,7 @@ public function getTimeToLive()
*/
public function setRestrictedPackageName($name)
{
if (!is_null($name) && !(is_string($name) && strlen($name) > 0)) {
if (null !== $name && !(is_string($name) && strlen($name) > 0)) {
throw new Exception\InvalidArgumentException('$name must be null OR a non-empty string');
}
$this->restrictedPackageName = $name;
Expand Down Expand Up @@ -298,7 +306,7 @@ public function getDryRun()
*/
public function toJson()
{
$json = array();
$json = [];
if ($this->registrationIds) {
$json['registration_ids'] = $this->registrationIds;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ class Response
/**
* Constructor
*
* @param string $response
* @param string $response
* @param Message $message
*
* @return Response
* @throws Exception\ServerUnavailable
*
* @throws \ZendService\Google\Exception\InvalidArgumentException
*/
public function __construct($response = null, Message $message = null)
{
Expand Down Expand Up @@ -135,19 +137,17 @@ public function getResponse()
*/
public function setResponse(array $response)
{
if (!isset($response['results']) ||
!isset($response['success']) ||
!isset($response['failure']) ||
!isset($response['canonical_ids']) ||
!isset($response['multicast_id'])) {
if (! isset($response['results'], $response['success'], $response['failure'], $response['canonical_ids'], $response['multicast_id'])) {
throw new Exception\InvalidArgumentException('Response did not contain the proper fields');
}
$this->response = $response;
$this->results = $response['results'];
$this->cntSuccess = (int) $response['success'];
$this->cntFailure = (int) $response['failure'];

$this->response = $response;
$this->results = $response['results'];
$this->cntSuccess = (int) $response['success'];
$this->cntFailure = (int) $response['failure'];
$this->cntCanonical = (int) $response['canonical_ids'];
$this->id = (int) $response['multicast_id'];
$this->id = (int) $response['multicast_id'];

return $this;
}

Expand Down Expand Up @@ -186,11 +186,11 @@ public function getCanonicalCount()
*
* @return array multi dimensional array of:
* NOTE: key is registration_id if the message is passed.
* 'registration_id' => array(
* 'registration_id' => [
* 'message_id' => 'id',
* 'error' => 'error',
* 'registration_id' => 'id'
* )
* ]
*/
public function getResults()
{
Expand All @@ -206,7 +206,7 @@ public function getResults()
*/
public function getResult($flag)
{
$ret = array();
$ret = [];
foreach ($this->correlate() as $k => $v) {
if (isset($v[$flag])) {
$ret[$k] = $v[$flag];
Expand Down
4 changes: 2 additions & 2 deletions tests/phpunit.xml.dist → phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<phpunit bootstrap="./Bootstrap.php" colors="true">
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="ZendService Google Gcm Test Suite">
<directory>./ZendService</directory>
<directory>./tests</directory>
</testsuite>
</testsuites>

Expand Down
2 changes: 0 additions & 2 deletions tests/.gitignore

This file was deleted.

92 changes: 0 additions & 92 deletions tests/Bootstrap.php

This file was deleted.

Loading