├── .gitignore ├── LICENSE ├── README.md ├── composer.json ├── composer.lock ├── phpunit.xml.dist ├── src ├── Client.php ├── ClientInterface.php ├── Message.php ├── Notification.php └── Recipient │ ├── Device.php │ ├── Recipient.php │ └── Topic.php └── tests ├── ClientTest.php ├── MessageTest.php ├── NotificationTest.php ├── PhpFirebaseCloudMessagingTestCase.php └── bootstrap.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor 2 | .project 3 | .buildpath 4 | .settings 5 | .idea 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 sngrl 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PHP Firebase Cloud Messaging 2 | PHP API for Firebase Cloud Messaging from Google. 3 | 4 | Currently this app server library only supports sending Messages/Notifications via HTTP. 5 | 6 | See original Firebase docs: https://firebase.google.com/docs/ 7 | 8 | #Setup 9 | Install via Composer: 10 | ``` 11 | composer require sngrl/php-firebase-cloud-messaging 12 | ``` 13 | 14 | Or add this to your composer.json and run "composer update": 15 | 16 | ``` 17 | "require": { 18 | "sngrl/php-firebase-cloud-messaging": "dev-master" 19 | } 20 | ``` 21 | 22 | #Send message to Device 23 | ``` 24 | use sngrl\PhpFirebaseCloudMessaging\Client; 25 | use sngrl\PhpFirebaseCloudMessaging\Message; 26 | use sngrl\PhpFirebaseCloudMessaging\Recipient\Device; 27 | use sngrl\PhpFirebaseCloudMessaging\Notification; 28 | 29 | $server_key = '_YOUR_SERVER_KEY_'; 30 | $client = new Client(); 31 | $client->setApiKey($server_key); 32 | $client->injectGuzzleHttpClient(new \GuzzleHttp\Client()); 33 | 34 | $message = new Message(); 35 | $message->setPriority('high'); 36 | $message->addRecipient(new Device('_YOUR_DEVICE_TOKEN_')); 37 | $message 38 | ->setNotification(new Notification('some title', 'some body')) 39 | ->setData(['key' => 'value']) 40 | ; 41 | 42 | $response = $client->send($message); 43 | var_dump($response->getStatusCode()); 44 | var_dump($response->getBody()->getContents()); 45 | ``` 46 | 47 | #Send message to multiple Devices 48 | 49 | ``` 50 | ... 51 | $message = new Message(); 52 | $message->setPriority('high'); 53 | $message->addRecipient(new Device('_YOUR_DEVICE_TOKEN_')); 54 | $message->addRecipient(new Device('_YOUR_DEVICE_TOKEN_2_')); 55 | $message->addRecipient(new Device('_YOUR_DEVICE_TOKEN_3_')); 56 | $message 57 | ->setNotification(new Notification('some title', 'some body')) 58 | ->setData(['key' => 'value']) 59 | ; 60 | ... 61 | ``` 62 | #Send message to Topic 63 | 64 | ``` 65 | use sngrl\PhpFirebaseCloudMessaging\Client; 66 | use sngrl\PhpFirebaseCloudMessaging\Message; 67 | use sngrl\PhpFirebaseCloudMessaging\Recipient\Topic; 68 | use sngrl\PhpFirebaseCloudMessaging\Notification; 69 | 70 | $server_key = '_YOUR_SERVER_KEY_'; 71 | $client = new Client(); 72 | $client->setApiKey($server_key); 73 | $client->injectGuzzleHttpClient(new \GuzzleHttp\Client()); 74 | 75 | $message = new Message(); 76 | $message->setPriority('high'); 77 | $message->addRecipient(new Topic('_YOUR_TOPIC_')); 78 | $message 79 | ->setNotification(new Notification('some title', 'some body')) 80 | ->setData(['key' => 'value']) 81 | ; 82 | 83 | $response = $client->send($message); 84 | var_dump($response->getStatusCode()); 85 | var_dump($response->getBody()->getContents()); 86 | ``` 87 | 88 | #Send message to multiple Topics 89 | 90 | See Firebase documentation for sending to [combinations of multiple topics](https://firebase.google.com/docs/cloud-messaging/topic-messaging#sending_topic_messages_from_the_server). 91 | 92 | ``` 93 | ... 94 | $message = new Message(); 95 | $message->setPriority('high'); 96 | $message->addRecipient(new Topic('_YOUR_TOPIC_')); 97 | $message->addRecipient(new Topic('_YOUR_TOPIC_2_')); 98 | $message->addRecipient(new Topic('_YOUR_TOPIC_3_')); 99 | $message 100 | ->setNotification(new Notification('some title', 'some body')) 101 | ->setData(['key' => 'value']) 102 | // Will send to devices subscribed to topic 1 AND topic 2 or 3 103 | ->setCondition('%s && (%s || %s)') 104 | ; 105 | ... 106 | ``` 107 | 108 | #Subscribe user to the topic 109 | ``` 110 | use sngrl\PhpFirebaseCloudMessaging\Client; 111 | 112 | $server_key = '_YOUR_SERVER_KEY_'; 113 | $client = new Client(); 114 | $client->setApiKey($server_key); 115 | $client->injectGuzzleHttpClient(new \GuzzleHttp\Client()); 116 | 117 | $response = $client->addTopicSubscription('_SOME_TOPIC_ID_', ['_FIRST_TOKEN_', '_SECOND_TOKEN_']); 118 | var_dump($response->getStatusCode()); 119 | var_dump($response->getBody()->getContents()); 120 | ``` 121 | 122 | #Remove user subscription to the topic 123 | ``` 124 | use sngrl\PhpFirebaseCloudMessaging\Client; 125 | 126 | $server_key = '_YOUR_SERVER_KEY_'; 127 | $client = new Client(); 128 | $client->setApiKey($server_key); 129 | $client->injectGuzzleHttpClient(new \GuzzleHttp\Client()); 130 | 131 | $response = $client->removeTopicSubscription('_SOME_TOPIC_ID_', ['_FIRST_TOKEN_', '_SECOND_TOKEN_']); 132 | var_dump($response->getStatusCode()); 133 | var_dump($response->getBody()->getContents()); 134 | ``` 135 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sngrl/php-firebase-cloud-messaging", 3 | "description": "PHP API for Firebase Cloud Messaging from Google", 4 | "license": "MIT", 5 | "keywords": ["PHP","FCM","Google","Firebase","Cloud","Notifications","Android","iOS","Chrome"], 6 | "homepage": "https://github.com/sngrl/php-firebase-cloud-messaging", 7 | "authors": [ 8 | { 9 | "name": "Sngrl", 10 | "email": "i@sngrl.ru" 11 | } 12 | ], 13 | "require": { 14 | "guzzlehttp/guzzle": "*", 15 | "php": ">=5.5" 16 | }, 17 | "require-dev": { 18 | "phpunit/phpunit": "*", 19 | "mockery/mockery" : "*" 20 | }, 21 | "autoload": { 22 | "psr-4": { 23 | "sngrl\\PhpFirebaseCloudMessaging\\": "src/" 24 | } 25 | }, 26 | "autoload-dev": { 27 | "psr-4": { 28 | "sngrl\\PhpFirebaseCloudMessaging\\Tests\\": "tests/" 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "ab504c85e705ff02c8dcbe03332f6141", 8 | "content-hash": "ef84c0b0bad4a256d5df81efde036b38", 9 | "packages": [ 10 | { 11 | "name": "guzzlehttp/guzzle", 12 | "version": "6.2.0", 13 | "source": { 14 | "type": "git", 15 | "url": "https://github.com/guzzle/guzzle.git", 16 | "reference": "d094e337976dff9d8e2424e8485872194e768662" 17 | }, 18 | "dist": { 19 | "type": "zip", 20 | "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d094e337976dff9d8e2424e8485872194e768662", 21 | "reference": "d094e337976dff9d8e2424e8485872194e768662", 22 | "shasum": "" 23 | }, 24 | "require": { 25 | "guzzlehttp/promises": "~1.0", 26 | "guzzlehttp/psr7": "~1.1", 27 | "php": ">=5.5.0" 28 | }, 29 | "require-dev": { 30 | "ext-curl": "*", 31 | "phpunit/phpunit": "~4.0", 32 | "psr/log": "~1.0" 33 | }, 34 | "type": "library", 35 | "extra": { 36 | "branch-alias": { 37 | "dev-master": "6.2-dev" 38 | } 39 | }, 40 | "autoload": { 41 | "files": [ 42 | "src/functions_include.php" 43 | ], 44 | "psr-4": { 45 | "GuzzleHttp\\": "src/" 46 | } 47 | }, 48 | "notification-url": "https://packagist.org/downloads/", 49 | "license": [ 50 | "MIT" 51 | ], 52 | "authors": [ 53 | { 54 | "name": "Michael Dowling", 55 | "email": "mtdowling@gmail.com", 56 | "homepage": "https://github.com/mtdowling" 57 | } 58 | ], 59 | "description": "Guzzle is a PHP HTTP client library", 60 | "homepage": "http://guzzlephp.org/", 61 | "keywords": [ 62 | "client", 63 | "curl", 64 | "framework", 65 | "http", 66 | "http client", 67 | "rest", 68 | "web service" 69 | ], 70 | "time": "2016-03-21 20:02:09" 71 | }, 72 | { 73 | "name": "guzzlehttp/promises", 74 | "version": "1.2.0", 75 | "source": { 76 | "type": "git", 77 | "url": "https://github.com/guzzle/promises.git", 78 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579" 79 | }, 80 | "dist": { 81 | "type": "zip", 82 | "url": "https://api.github.com/repos/guzzle/promises/zipball/c10d860e2a9595f8883527fa0021c7da9e65f579", 83 | "reference": "c10d860e2a9595f8883527fa0021c7da9e65f579", 84 | "shasum": "" 85 | }, 86 | "require": { 87 | "php": ">=5.5.0" 88 | }, 89 | "require-dev": { 90 | "phpunit/phpunit": "~4.0" 91 | }, 92 | "type": "library", 93 | "extra": { 94 | "branch-alias": { 95 | "dev-master": "1.0-dev" 96 | } 97 | }, 98 | "autoload": { 99 | "psr-4": { 100 | "GuzzleHttp\\Promise\\": "src/" 101 | }, 102 | "files": [ 103 | "src/functions_include.php" 104 | ] 105 | }, 106 | "notification-url": "https://packagist.org/downloads/", 107 | "license": [ 108 | "MIT" 109 | ], 110 | "authors": [ 111 | { 112 | "name": "Michael Dowling", 113 | "email": "mtdowling@gmail.com", 114 | "homepage": "https://github.com/mtdowling" 115 | } 116 | ], 117 | "description": "Guzzle promises library", 118 | "keywords": [ 119 | "promise" 120 | ], 121 | "time": "2016-05-18 16:56:05" 122 | }, 123 | { 124 | "name": "guzzlehttp/psr7", 125 | "version": "1.3.0", 126 | "source": { 127 | "type": "git", 128 | "url": "https://github.com/guzzle/psr7.git", 129 | "reference": "31382fef2889136415751badebbd1cb022a4ed72" 130 | }, 131 | "dist": { 132 | "type": "zip", 133 | "url": "https://api.github.com/repos/guzzle/psr7/zipball/31382fef2889136415751badebbd1cb022a4ed72", 134 | "reference": "31382fef2889136415751badebbd1cb022a4ed72", 135 | "shasum": "" 136 | }, 137 | "require": { 138 | "php": ">=5.4.0", 139 | "psr/http-message": "~1.0" 140 | }, 141 | "provide": { 142 | "psr/http-message-implementation": "1.0" 143 | }, 144 | "require-dev": { 145 | "phpunit/phpunit": "~4.0" 146 | }, 147 | "type": "library", 148 | "extra": { 149 | "branch-alias": { 150 | "dev-master": "1.0-dev" 151 | } 152 | }, 153 | "autoload": { 154 | "psr-4": { 155 | "GuzzleHttp\\Psr7\\": "src/" 156 | }, 157 | "files": [ 158 | "src/functions_include.php" 159 | ] 160 | }, 161 | "notification-url": "https://packagist.org/downloads/", 162 | "license": [ 163 | "MIT" 164 | ], 165 | "authors": [ 166 | { 167 | "name": "Michael Dowling", 168 | "email": "mtdowling@gmail.com", 169 | "homepage": "https://github.com/mtdowling" 170 | } 171 | ], 172 | "description": "PSR-7 message implementation", 173 | "keywords": [ 174 | "http", 175 | "message", 176 | "stream", 177 | "uri" 178 | ], 179 | "time": "2016-04-13 19:56:01" 180 | }, 181 | { 182 | "name": "psr/http-message", 183 | "version": "1.0", 184 | "source": { 185 | "type": "git", 186 | "url": "https://github.com/php-fig/http-message.git", 187 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" 188 | }, 189 | "dist": { 190 | "type": "zip", 191 | "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 192 | "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", 193 | "shasum": "" 194 | }, 195 | "require": { 196 | "php": ">=5.3.0" 197 | }, 198 | "type": "library", 199 | "extra": { 200 | "branch-alias": { 201 | "dev-master": "1.0.x-dev" 202 | } 203 | }, 204 | "autoload": { 205 | "psr-4": { 206 | "Psr\\Http\\Message\\": "src/" 207 | } 208 | }, 209 | "notification-url": "https://packagist.org/downloads/", 210 | "license": [ 211 | "MIT" 212 | ], 213 | "authors": [ 214 | { 215 | "name": "PHP-FIG", 216 | "homepage": "http://www.php-fig.org/" 217 | } 218 | ], 219 | "description": "Common interface for HTTP messages", 220 | "keywords": [ 221 | "http", 222 | "http-message", 223 | "psr", 224 | "psr-7", 225 | "request", 226 | "response" 227 | ], 228 | "time": "2015-05-04 20:22:00" 229 | } 230 | ], 231 | "packages-dev": [ 232 | { 233 | "name": "doctrine/instantiator", 234 | "version": "1.0.5", 235 | "source": { 236 | "type": "git", 237 | "url": "https://github.com/doctrine/instantiator.git", 238 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" 239 | }, 240 | "dist": { 241 | "type": "zip", 242 | "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", 243 | "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", 244 | "shasum": "" 245 | }, 246 | "require": { 247 | "php": ">=5.3,<8.0-DEV" 248 | }, 249 | "require-dev": { 250 | "athletic/athletic": "~0.1.8", 251 | "ext-pdo": "*", 252 | "ext-phar": "*", 253 | "phpunit/phpunit": "~4.0", 254 | "squizlabs/php_codesniffer": "~2.0" 255 | }, 256 | "type": "library", 257 | "extra": { 258 | "branch-alias": { 259 | "dev-master": "1.0.x-dev" 260 | } 261 | }, 262 | "autoload": { 263 | "psr-4": { 264 | "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" 265 | } 266 | }, 267 | "notification-url": "https://packagist.org/downloads/", 268 | "license": [ 269 | "MIT" 270 | ], 271 | "authors": [ 272 | { 273 | "name": "Marco Pivetta", 274 | "email": "ocramius@gmail.com", 275 | "homepage": "http://ocramius.github.com/" 276 | } 277 | ], 278 | "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", 279 | "homepage": "https://github.com/doctrine/instantiator", 280 | "keywords": [ 281 | "constructor", 282 | "instantiate" 283 | ], 284 | "time": "2015-06-14 21:17:01" 285 | }, 286 | { 287 | "name": "hamcrest/hamcrest-php", 288 | "version": "v1.2.2", 289 | "source": { 290 | "type": "git", 291 | "url": "https://github.com/hamcrest/hamcrest-php.git", 292 | "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" 293 | }, 294 | "dist": { 295 | "type": "zip", 296 | "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", 297 | "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", 298 | "shasum": "" 299 | }, 300 | "require": { 301 | "php": ">=5.3.2" 302 | }, 303 | "replace": { 304 | "cordoval/hamcrest-php": "*", 305 | "davedevelopment/hamcrest-php": "*", 306 | "kodova/hamcrest-php": "*" 307 | }, 308 | "require-dev": { 309 | "phpunit/php-file-iterator": "1.3.3", 310 | "satooshi/php-coveralls": "dev-master" 311 | }, 312 | "type": "library", 313 | "autoload": { 314 | "classmap": [ 315 | "hamcrest" 316 | ], 317 | "files": [ 318 | "hamcrest/Hamcrest.php" 319 | ] 320 | }, 321 | "notification-url": "https://packagist.org/downloads/", 322 | "license": [ 323 | "BSD" 324 | ], 325 | "description": "This is the PHP port of Hamcrest Matchers", 326 | "keywords": [ 327 | "test" 328 | ], 329 | "time": "2015-05-11 14:41:42" 330 | }, 331 | { 332 | "name": "mockery/mockery", 333 | "version": "0.9.5", 334 | "source": { 335 | "type": "git", 336 | "url": "https://github.com/padraic/mockery.git", 337 | "reference": "4db079511a283e5aba1b3c2fb19037c645e70fc2" 338 | }, 339 | "dist": { 340 | "type": "zip", 341 | "url": "https://api.github.com/repos/padraic/mockery/zipball/4db079511a283e5aba1b3c2fb19037c645e70fc2", 342 | "reference": "4db079511a283e5aba1b3c2fb19037c645e70fc2", 343 | "shasum": "" 344 | }, 345 | "require": { 346 | "hamcrest/hamcrest-php": "~1.1", 347 | "lib-pcre": ">=7.0", 348 | "php": ">=5.3.2" 349 | }, 350 | "require-dev": { 351 | "phpunit/phpunit": "~4.0" 352 | }, 353 | "type": "library", 354 | "extra": { 355 | "branch-alias": { 356 | "dev-master": "0.9.x-dev" 357 | } 358 | }, 359 | "autoload": { 360 | "psr-0": { 361 | "Mockery": "library/" 362 | } 363 | }, 364 | "notification-url": "https://packagist.org/downloads/", 365 | "license": [ 366 | "BSD-3-Clause" 367 | ], 368 | "authors": [ 369 | { 370 | "name": "Pádraic Brady", 371 | "email": "padraic.brady@gmail.com", 372 | "homepage": "http://blog.astrumfutura.com" 373 | }, 374 | { 375 | "name": "Dave Marshall", 376 | "email": "dave.marshall@atstsolutions.co.uk", 377 | "homepage": "http://davedevelopment.co.uk" 378 | } 379 | ], 380 | "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", 381 | "homepage": "http://github.com/padraic/mockery", 382 | "keywords": [ 383 | "BDD", 384 | "TDD", 385 | "library", 386 | "mock", 387 | "mock objects", 388 | "mockery", 389 | "stub", 390 | "test", 391 | "test double", 392 | "testing" 393 | ], 394 | "time": "2016-05-22 21:52:33" 395 | }, 396 | { 397 | "name": "myclabs/deep-copy", 398 | "version": "1.5.1", 399 | "source": { 400 | "type": "git", 401 | "url": "https://github.com/myclabs/DeepCopy.git", 402 | "reference": "a8773992b362b58498eed24bf85005f363c34771" 403 | }, 404 | "dist": { 405 | "type": "zip", 406 | "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/a8773992b362b58498eed24bf85005f363c34771", 407 | "reference": "a8773992b362b58498eed24bf85005f363c34771", 408 | "shasum": "" 409 | }, 410 | "require": { 411 | "php": ">=5.4.0" 412 | }, 413 | "require-dev": { 414 | "doctrine/collections": "1.*", 415 | "phpunit/phpunit": "~4.1" 416 | }, 417 | "type": "library", 418 | "autoload": { 419 | "psr-4": { 420 | "DeepCopy\\": "src/DeepCopy/" 421 | } 422 | }, 423 | "notification-url": "https://packagist.org/downloads/", 424 | "license": [ 425 | "MIT" 426 | ], 427 | "description": "Create deep copies (clones) of your objects", 428 | "homepage": "https://github.com/myclabs/DeepCopy", 429 | "keywords": [ 430 | "clone", 431 | "copy", 432 | "duplicate", 433 | "object", 434 | "object graph" 435 | ], 436 | "time": "2015-11-20 12:04:31" 437 | }, 438 | { 439 | "name": "phpdocumentor/reflection-docblock", 440 | "version": "2.0.4", 441 | "source": { 442 | "type": "git", 443 | "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", 444 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" 445 | }, 446 | "dist": { 447 | "type": "zip", 448 | "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", 449 | "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", 450 | "shasum": "" 451 | }, 452 | "require": { 453 | "php": ">=5.3.3" 454 | }, 455 | "require-dev": { 456 | "phpunit/phpunit": "~4.0" 457 | }, 458 | "suggest": { 459 | "dflydev/markdown": "~1.0", 460 | "erusev/parsedown": "~1.0" 461 | }, 462 | "type": "library", 463 | "extra": { 464 | "branch-alias": { 465 | "dev-master": "2.0.x-dev" 466 | } 467 | }, 468 | "autoload": { 469 | "psr-0": { 470 | "phpDocumentor": [ 471 | "src/" 472 | ] 473 | } 474 | }, 475 | "notification-url": "https://packagist.org/downloads/", 476 | "license": [ 477 | "MIT" 478 | ], 479 | "authors": [ 480 | { 481 | "name": "Mike van Riel", 482 | "email": "mike.vanriel@naenius.com" 483 | } 484 | ], 485 | "time": "2015-02-03 12:10:50" 486 | }, 487 | { 488 | "name": "phpspec/prophecy", 489 | "version": "v1.6.0", 490 | "source": { 491 | "type": "git", 492 | "url": "https://github.com/phpspec/prophecy.git", 493 | "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972" 494 | }, 495 | "dist": { 496 | "type": "zip", 497 | "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972", 498 | "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972", 499 | "shasum": "" 500 | }, 501 | "require": { 502 | "doctrine/instantiator": "^1.0.2", 503 | "php": "^5.3|^7.0", 504 | "phpdocumentor/reflection-docblock": "~2.0", 505 | "sebastian/comparator": "~1.1", 506 | "sebastian/recursion-context": "~1.0" 507 | }, 508 | "require-dev": { 509 | "phpspec/phpspec": "~2.0" 510 | }, 511 | "type": "library", 512 | "extra": { 513 | "branch-alias": { 514 | "dev-master": "1.5.x-dev" 515 | } 516 | }, 517 | "autoload": { 518 | "psr-0": { 519 | "Prophecy\\": "src/" 520 | } 521 | }, 522 | "notification-url": "https://packagist.org/downloads/", 523 | "license": [ 524 | "MIT" 525 | ], 526 | "authors": [ 527 | { 528 | "name": "Konstantin Kudryashov", 529 | "email": "ever.zet@gmail.com", 530 | "homepage": "http://everzet.com" 531 | }, 532 | { 533 | "name": "Marcello Duarte", 534 | "email": "marcello.duarte@gmail.com" 535 | } 536 | ], 537 | "description": "Highly opinionated mocking framework for PHP 5.3+", 538 | "homepage": "https://github.com/phpspec/prophecy", 539 | "keywords": [ 540 | "Double", 541 | "Dummy", 542 | "fake", 543 | "mock", 544 | "spy", 545 | "stub" 546 | ], 547 | "time": "2016-02-15 07:46:21" 548 | }, 549 | { 550 | "name": "phpunit/php-code-coverage", 551 | "version": "3.3.3", 552 | "source": { 553 | "type": "git", 554 | "url": "https://github.com/sebastianbergmann/php-code-coverage.git", 555 | "reference": "44cd8e3930e431658d1a5de7d282d5cb37837fd5" 556 | }, 557 | "dist": { 558 | "type": "zip", 559 | "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/44cd8e3930e431658d1a5de7d282d5cb37837fd5", 560 | "reference": "44cd8e3930e431658d1a5de7d282d5cb37837fd5", 561 | "shasum": "" 562 | }, 563 | "require": { 564 | "php": "^5.6 || ^7.0", 565 | "phpunit/php-file-iterator": "~1.3", 566 | "phpunit/php-text-template": "~1.2", 567 | "phpunit/php-token-stream": "^1.4.2", 568 | "sebastian/code-unit-reverse-lookup": "~1.0", 569 | "sebastian/environment": "^1.3.2", 570 | "sebastian/version": "~1.0|~2.0" 571 | }, 572 | "require-dev": { 573 | "ext-xdebug": ">=2.1.4", 574 | "phpunit/phpunit": "~5" 575 | }, 576 | "suggest": { 577 | "ext-dom": "*", 578 | "ext-xdebug": ">=2.4.0", 579 | "ext-xmlwriter": "*" 580 | }, 581 | "type": "library", 582 | "extra": { 583 | "branch-alias": { 584 | "dev-master": "3.3.x-dev" 585 | } 586 | }, 587 | "autoload": { 588 | "classmap": [ 589 | "src/" 590 | ] 591 | }, 592 | "notification-url": "https://packagist.org/downloads/", 593 | "license": [ 594 | "BSD-3-Clause" 595 | ], 596 | "authors": [ 597 | { 598 | "name": "Sebastian Bergmann", 599 | "email": "sb@sebastian-bergmann.de", 600 | "role": "lead" 601 | } 602 | ], 603 | "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", 604 | "homepage": "https://github.com/sebastianbergmann/php-code-coverage", 605 | "keywords": [ 606 | "coverage", 607 | "testing", 608 | "xunit" 609 | ], 610 | "time": "2016-05-27 16:24:29" 611 | }, 612 | { 613 | "name": "phpunit/php-file-iterator", 614 | "version": "1.4.1", 615 | "source": { 616 | "type": "git", 617 | "url": "https://github.com/sebastianbergmann/php-file-iterator.git", 618 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" 619 | }, 620 | "dist": { 621 | "type": "zip", 622 | "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", 623 | "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", 624 | "shasum": "" 625 | }, 626 | "require": { 627 | "php": ">=5.3.3" 628 | }, 629 | "type": "library", 630 | "extra": { 631 | "branch-alias": { 632 | "dev-master": "1.4.x-dev" 633 | } 634 | }, 635 | "autoload": { 636 | "classmap": [ 637 | "src/" 638 | ] 639 | }, 640 | "notification-url": "https://packagist.org/downloads/", 641 | "license": [ 642 | "BSD-3-Clause" 643 | ], 644 | "authors": [ 645 | { 646 | "name": "Sebastian Bergmann", 647 | "email": "sb@sebastian-bergmann.de", 648 | "role": "lead" 649 | } 650 | ], 651 | "description": "FilterIterator implementation that filters files based on a list of suffixes.", 652 | "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", 653 | "keywords": [ 654 | "filesystem", 655 | "iterator" 656 | ], 657 | "time": "2015-06-21 13:08:43" 658 | }, 659 | { 660 | "name": "phpunit/php-text-template", 661 | "version": "1.2.1", 662 | "source": { 663 | "type": "git", 664 | "url": "https://github.com/sebastianbergmann/php-text-template.git", 665 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" 666 | }, 667 | "dist": { 668 | "type": "zip", 669 | "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 670 | "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", 671 | "shasum": "" 672 | }, 673 | "require": { 674 | "php": ">=5.3.3" 675 | }, 676 | "type": "library", 677 | "autoload": { 678 | "classmap": [ 679 | "src/" 680 | ] 681 | }, 682 | "notification-url": "https://packagist.org/downloads/", 683 | "license": [ 684 | "BSD-3-Clause" 685 | ], 686 | "authors": [ 687 | { 688 | "name": "Sebastian Bergmann", 689 | "email": "sebastian@phpunit.de", 690 | "role": "lead" 691 | } 692 | ], 693 | "description": "Simple template engine.", 694 | "homepage": "https://github.com/sebastianbergmann/php-text-template/", 695 | "keywords": [ 696 | "template" 697 | ], 698 | "time": "2015-06-21 13:50:34" 699 | }, 700 | { 701 | "name": "phpunit/php-timer", 702 | "version": "1.0.8", 703 | "source": { 704 | "type": "git", 705 | "url": "https://github.com/sebastianbergmann/php-timer.git", 706 | "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" 707 | }, 708 | "dist": { 709 | "type": "zip", 710 | "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", 711 | "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", 712 | "shasum": "" 713 | }, 714 | "require": { 715 | "php": ">=5.3.3" 716 | }, 717 | "require-dev": { 718 | "phpunit/phpunit": "~4|~5" 719 | }, 720 | "type": "library", 721 | "autoload": { 722 | "classmap": [ 723 | "src/" 724 | ] 725 | }, 726 | "notification-url": "https://packagist.org/downloads/", 727 | "license": [ 728 | "BSD-3-Clause" 729 | ], 730 | "authors": [ 731 | { 732 | "name": "Sebastian Bergmann", 733 | "email": "sb@sebastian-bergmann.de", 734 | "role": "lead" 735 | } 736 | ], 737 | "description": "Utility class for timing", 738 | "homepage": "https://github.com/sebastianbergmann/php-timer/", 739 | "keywords": [ 740 | "timer" 741 | ], 742 | "time": "2016-05-12 18:03:57" 743 | }, 744 | { 745 | "name": "phpunit/php-token-stream", 746 | "version": "1.4.8", 747 | "source": { 748 | "type": "git", 749 | "url": "https://github.com/sebastianbergmann/php-token-stream.git", 750 | "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" 751 | }, 752 | "dist": { 753 | "type": "zip", 754 | "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", 755 | "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", 756 | "shasum": "" 757 | }, 758 | "require": { 759 | "ext-tokenizer": "*", 760 | "php": ">=5.3.3" 761 | }, 762 | "require-dev": { 763 | "phpunit/phpunit": "~4.2" 764 | }, 765 | "type": "library", 766 | "extra": { 767 | "branch-alias": { 768 | "dev-master": "1.4-dev" 769 | } 770 | }, 771 | "autoload": { 772 | "classmap": [ 773 | "src/" 774 | ] 775 | }, 776 | "notification-url": "https://packagist.org/downloads/", 777 | "license": [ 778 | "BSD-3-Clause" 779 | ], 780 | "authors": [ 781 | { 782 | "name": "Sebastian Bergmann", 783 | "email": "sebastian@phpunit.de" 784 | } 785 | ], 786 | "description": "Wrapper around PHP's tokenizer extension.", 787 | "homepage": "https://github.com/sebastianbergmann/php-token-stream/", 788 | "keywords": [ 789 | "tokenizer" 790 | ], 791 | "time": "2015-09-15 10:49:45" 792 | }, 793 | { 794 | "name": "phpunit/phpunit", 795 | "version": "5.3.4", 796 | "source": { 797 | "type": "git", 798 | "url": "https://github.com/sebastianbergmann/phpunit.git", 799 | "reference": "00dd95ffb48805503817ced06399017df315fe5c" 800 | }, 801 | "dist": { 802 | "type": "zip", 803 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/00dd95ffb48805503817ced06399017df315fe5c", 804 | "reference": "00dd95ffb48805503817ced06399017df315fe5c", 805 | "shasum": "" 806 | }, 807 | "require": { 808 | "ext-dom": "*", 809 | "ext-json": "*", 810 | "ext-pcre": "*", 811 | "ext-reflection": "*", 812 | "ext-spl": "*", 813 | "myclabs/deep-copy": "~1.3", 814 | "php": "^5.6 || ^7.0", 815 | "phpspec/prophecy": "^1.3.1", 816 | "phpunit/php-code-coverage": "^3.3.0", 817 | "phpunit/php-file-iterator": "~1.4", 818 | "phpunit/php-text-template": "~1.2", 819 | "phpunit/php-timer": "^1.0.6", 820 | "phpunit/phpunit-mock-objects": "^3.1", 821 | "sebastian/comparator": "~1.1", 822 | "sebastian/diff": "~1.2", 823 | "sebastian/environment": "~1.3", 824 | "sebastian/exporter": "~1.2", 825 | "sebastian/global-state": "~1.0", 826 | "sebastian/object-enumerator": "~1.0", 827 | "sebastian/resource-operations": "~1.0", 828 | "sebastian/version": "~1.0|~2.0", 829 | "symfony/yaml": "~2.1|~3.0" 830 | }, 831 | "suggest": { 832 | "phpunit/php-invoker": "~1.1" 833 | }, 834 | "bin": [ 835 | "phpunit" 836 | ], 837 | "type": "library", 838 | "extra": { 839 | "branch-alias": { 840 | "dev-master": "5.3.x-dev" 841 | } 842 | }, 843 | "autoload": { 844 | "classmap": [ 845 | "src/" 846 | ] 847 | }, 848 | "notification-url": "https://packagist.org/downloads/", 849 | "license": [ 850 | "BSD-3-Clause" 851 | ], 852 | "authors": [ 853 | { 854 | "name": "Sebastian Bergmann", 855 | "email": "sebastian@phpunit.de", 856 | "role": "lead" 857 | } 858 | ], 859 | "description": "The PHP Unit Testing framework.", 860 | "homepage": "https://phpunit.de/", 861 | "keywords": [ 862 | "phpunit", 863 | "testing", 864 | "xunit" 865 | ], 866 | "time": "2016-05-11 13:28:45" 867 | }, 868 | { 869 | "name": "phpunit/phpunit-mock-objects", 870 | "version": "3.1.3", 871 | "source": { 872 | "type": "git", 873 | "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", 874 | "reference": "151c96874bff6fe61a25039df60e776613a61489" 875 | }, 876 | "dist": { 877 | "type": "zip", 878 | "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/151c96874bff6fe61a25039df60e776613a61489", 879 | "reference": "151c96874bff6fe61a25039df60e776613a61489", 880 | "shasum": "" 881 | }, 882 | "require": { 883 | "doctrine/instantiator": "^1.0.2", 884 | "php": ">=5.6", 885 | "phpunit/php-text-template": "~1.2", 886 | "sebastian/exporter": "~1.2" 887 | }, 888 | "require-dev": { 889 | "phpunit/phpunit": "~5" 890 | }, 891 | "suggest": { 892 | "ext-soap": "*" 893 | }, 894 | "type": "library", 895 | "extra": { 896 | "branch-alias": { 897 | "dev-master": "3.1.x-dev" 898 | } 899 | }, 900 | "autoload": { 901 | "classmap": [ 902 | "src/" 903 | ] 904 | }, 905 | "notification-url": "https://packagist.org/downloads/", 906 | "license": [ 907 | "BSD-3-Clause" 908 | ], 909 | "authors": [ 910 | { 911 | "name": "Sebastian Bergmann", 912 | "email": "sb@sebastian-bergmann.de", 913 | "role": "lead" 914 | } 915 | ], 916 | "description": "Mock Object library for PHPUnit", 917 | "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", 918 | "keywords": [ 919 | "mock", 920 | "xunit" 921 | ], 922 | "time": "2016-04-20 14:39:26" 923 | }, 924 | { 925 | "name": "sebastian/code-unit-reverse-lookup", 926 | "version": "1.0.0", 927 | "source": { 928 | "type": "git", 929 | "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", 930 | "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe" 931 | }, 932 | "dist": { 933 | "type": "zip", 934 | "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/c36f5e7cfce482fde5bf8d10d41a53591e0198fe", 935 | "reference": "c36f5e7cfce482fde5bf8d10d41a53591e0198fe", 936 | "shasum": "" 937 | }, 938 | "require": { 939 | "php": ">=5.6" 940 | }, 941 | "require-dev": { 942 | "phpunit/phpunit": "~5" 943 | }, 944 | "type": "library", 945 | "extra": { 946 | "branch-alias": { 947 | "dev-master": "1.0.x-dev" 948 | } 949 | }, 950 | "autoload": { 951 | "classmap": [ 952 | "src/" 953 | ] 954 | }, 955 | "notification-url": "https://packagist.org/downloads/", 956 | "license": [ 957 | "BSD-3-Clause" 958 | ], 959 | "authors": [ 960 | { 961 | "name": "Sebastian Bergmann", 962 | "email": "sebastian@phpunit.de" 963 | } 964 | ], 965 | "description": "Looks up which function or method a line of code belongs to", 966 | "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", 967 | "time": "2016-02-13 06:45:14" 968 | }, 969 | { 970 | "name": "sebastian/comparator", 971 | "version": "1.2.0", 972 | "source": { 973 | "type": "git", 974 | "url": "https://github.com/sebastianbergmann/comparator.git", 975 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" 976 | }, 977 | "dist": { 978 | "type": "zip", 979 | "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", 980 | "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", 981 | "shasum": "" 982 | }, 983 | "require": { 984 | "php": ">=5.3.3", 985 | "sebastian/diff": "~1.2", 986 | "sebastian/exporter": "~1.2" 987 | }, 988 | "require-dev": { 989 | "phpunit/phpunit": "~4.4" 990 | }, 991 | "type": "library", 992 | "extra": { 993 | "branch-alias": { 994 | "dev-master": "1.2.x-dev" 995 | } 996 | }, 997 | "autoload": { 998 | "classmap": [ 999 | "src/" 1000 | ] 1001 | }, 1002 | "notification-url": "https://packagist.org/downloads/", 1003 | "license": [ 1004 | "BSD-3-Clause" 1005 | ], 1006 | "authors": [ 1007 | { 1008 | "name": "Jeff Welch", 1009 | "email": "whatthejeff@gmail.com" 1010 | }, 1011 | { 1012 | "name": "Volker Dusch", 1013 | "email": "github@wallbash.com" 1014 | }, 1015 | { 1016 | "name": "Bernhard Schussek", 1017 | "email": "bschussek@2bepublished.at" 1018 | }, 1019 | { 1020 | "name": "Sebastian Bergmann", 1021 | "email": "sebastian@phpunit.de" 1022 | } 1023 | ], 1024 | "description": "Provides the functionality to compare PHP values for equality", 1025 | "homepage": "http://www.github.com/sebastianbergmann/comparator", 1026 | "keywords": [ 1027 | "comparator", 1028 | "compare", 1029 | "equality" 1030 | ], 1031 | "time": "2015-07-26 15:48:44" 1032 | }, 1033 | { 1034 | "name": "sebastian/diff", 1035 | "version": "1.4.1", 1036 | "source": { 1037 | "type": "git", 1038 | "url": "https://github.com/sebastianbergmann/diff.git", 1039 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" 1040 | }, 1041 | "dist": { 1042 | "type": "zip", 1043 | "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", 1044 | "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", 1045 | "shasum": "" 1046 | }, 1047 | "require": { 1048 | "php": ">=5.3.3" 1049 | }, 1050 | "require-dev": { 1051 | "phpunit/phpunit": "~4.8" 1052 | }, 1053 | "type": "library", 1054 | "extra": { 1055 | "branch-alias": { 1056 | "dev-master": "1.4-dev" 1057 | } 1058 | }, 1059 | "autoload": { 1060 | "classmap": [ 1061 | "src/" 1062 | ] 1063 | }, 1064 | "notification-url": "https://packagist.org/downloads/", 1065 | "license": [ 1066 | "BSD-3-Clause" 1067 | ], 1068 | "authors": [ 1069 | { 1070 | "name": "Kore Nordmann", 1071 | "email": "mail@kore-nordmann.de" 1072 | }, 1073 | { 1074 | "name": "Sebastian Bergmann", 1075 | "email": "sebastian@phpunit.de" 1076 | } 1077 | ], 1078 | "description": "Diff implementation", 1079 | "homepage": "https://github.com/sebastianbergmann/diff", 1080 | "keywords": [ 1081 | "diff" 1082 | ], 1083 | "time": "2015-12-08 07:14:41" 1084 | }, 1085 | { 1086 | "name": "sebastian/environment", 1087 | "version": "1.3.7", 1088 | "source": { 1089 | "type": "git", 1090 | "url": "https://github.com/sebastianbergmann/environment.git", 1091 | "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716" 1092 | }, 1093 | "dist": { 1094 | "type": "zip", 1095 | "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/4e8f0da10ac5802913afc151413bc8c53b6c2716", 1096 | "reference": "4e8f0da10ac5802913afc151413bc8c53b6c2716", 1097 | "shasum": "" 1098 | }, 1099 | "require": { 1100 | "php": ">=5.3.3" 1101 | }, 1102 | "require-dev": { 1103 | "phpunit/phpunit": "~4.4" 1104 | }, 1105 | "type": "library", 1106 | "extra": { 1107 | "branch-alias": { 1108 | "dev-master": "1.3.x-dev" 1109 | } 1110 | }, 1111 | "autoload": { 1112 | "classmap": [ 1113 | "src/" 1114 | ] 1115 | }, 1116 | "notification-url": "https://packagist.org/downloads/", 1117 | "license": [ 1118 | "BSD-3-Clause" 1119 | ], 1120 | "authors": [ 1121 | { 1122 | "name": "Sebastian Bergmann", 1123 | "email": "sebastian@phpunit.de" 1124 | } 1125 | ], 1126 | "description": "Provides functionality to handle HHVM/PHP environments", 1127 | "homepage": "http://www.github.com/sebastianbergmann/environment", 1128 | "keywords": [ 1129 | "Xdebug", 1130 | "environment", 1131 | "hhvm" 1132 | ], 1133 | "time": "2016-05-17 03:18:57" 1134 | }, 1135 | { 1136 | "name": "sebastian/exporter", 1137 | "version": "1.2.1", 1138 | "source": { 1139 | "type": "git", 1140 | "url": "https://github.com/sebastianbergmann/exporter.git", 1141 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e" 1142 | }, 1143 | "dist": { 1144 | "type": "zip", 1145 | "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", 1146 | "reference": "7ae5513327cb536431847bcc0c10edba2701064e", 1147 | "shasum": "" 1148 | }, 1149 | "require": { 1150 | "php": ">=5.3.3", 1151 | "sebastian/recursion-context": "~1.0" 1152 | }, 1153 | "require-dev": { 1154 | "phpunit/phpunit": "~4.4" 1155 | }, 1156 | "type": "library", 1157 | "extra": { 1158 | "branch-alias": { 1159 | "dev-master": "1.2.x-dev" 1160 | } 1161 | }, 1162 | "autoload": { 1163 | "classmap": [ 1164 | "src/" 1165 | ] 1166 | }, 1167 | "notification-url": "https://packagist.org/downloads/", 1168 | "license": [ 1169 | "BSD-3-Clause" 1170 | ], 1171 | "authors": [ 1172 | { 1173 | "name": "Jeff Welch", 1174 | "email": "whatthejeff@gmail.com" 1175 | }, 1176 | { 1177 | "name": "Volker Dusch", 1178 | "email": "github@wallbash.com" 1179 | }, 1180 | { 1181 | "name": "Bernhard Schussek", 1182 | "email": "bschussek@2bepublished.at" 1183 | }, 1184 | { 1185 | "name": "Sebastian Bergmann", 1186 | "email": "sebastian@phpunit.de" 1187 | }, 1188 | { 1189 | "name": "Adam Harvey", 1190 | "email": "aharvey@php.net" 1191 | } 1192 | ], 1193 | "description": "Provides the functionality to export PHP variables for visualization", 1194 | "homepage": "http://www.github.com/sebastianbergmann/exporter", 1195 | "keywords": [ 1196 | "export", 1197 | "exporter" 1198 | ], 1199 | "time": "2015-06-21 07:55:53" 1200 | }, 1201 | { 1202 | "name": "sebastian/global-state", 1203 | "version": "1.1.1", 1204 | "source": { 1205 | "type": "git", 1206 | "url": "https://github.com/sebastianbergmann/global-state.git", 1207 | "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" 1208 | }, 1209 | "dist": { 1210 | "type": "zip", 1211 | "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", 1212 | "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", 1213 | "shasum": "" 1214 | }, 1215 | "require": { 1216 | "php": ">=5.3.3" 1217 | }, 1218 | "require-dev": { 1219 | "phpunit/phpunit": "~4.2" 1220 | }, 1221 | "suggest": { 1222 | "ext-uopz": "*" 1223 | }, 1224 | "type": "library", 1225 | "extra": { 1226 | "branch-alias": { 1227 | "dev-master": "1.0-dev" 1228 | } 1229 | }, 1230 | "autoload": { 1231 | "classmap": [ 1232 | "src/" 1233 | ] 1234 | }, 1235 | "notification-url": "https://packagist.org/downloads/", 1236 | "license": [ 1237 | "BSD-3-Clause" 1238 | ], 1239 | "authors": [ 1240 | { 1241 | "name": "Sebastian Bergmann", 1242 | "email": "sebastian@phpunit.de" 1243 | } 1244 | ], 1245 | "description": "Snapshotting of global state", 1246 | "homepage": "http://www.github.com/sebastianbergmann/global-state", 1247 | "keywords": [ 1248 | "global state" 1249 | ], 1250 | "time": "2015-10-12 03:26:01" 1251 | }, 1252 | { 1253 | "name": "sebastian/object-enumerator", 1254 | "version": "1.0.0", 1255 | "source": { 1256 | "type": "git", 1257 | "url": "https://github.com/sebastianbergmann/object-enumerator.git", 1258 | "reference": "d4ca2fb70344987502567bc50081c03e6192fb26" 1259 | }, 1260 | "dist": { 1261 | "type": "zip", 1262 | "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/d4ca2fb70344987502567bc50081c03e6192fb26", 1263 | "reference": "d4ca2fb70344987502567bc50081c03e6192fb26", 1264 | "shasum": "" 1265 | }, 1266 | "require": { 1267 | "php": ">=5.6", 1268 | "sebastian/recursion-context": "~1.0" 1269 | }, 1270 | "require-dev": { 1271 | "phpunit/phpunit": "~5" 1272 | }, 1273 | "type": "library", 1274 | "extra": { 1275 | "branch-alias": { 1276 | "dev-master": "1.0.x-dev" 1277 | } 1278 | }, 1279 | "autoload": { 1280 | "classmap": [ 1281 | "src/" 1282 | ] 1283 | }, 1284 | "notification-url": "https://packagist.org/downloads/", 1285 | "license": [ 1286 | "BSD-3-Clause" 1287 | ], 1288 | "authors": [ 1289 | { 1290 | "name": "Sebastian Bergmann", 1291 | "email": "sebastian@phpunit.de" 1292 | } 1293 | ], 1294 | "description": "Traverses array structures and object graphs to enumerate all referenced objects", 1295 | "homepage": "https://github.com/sebastianbergmann/object-enumerator/", 1296 | "time": "2016-01-28 13:25:10" 1297 | }, 1298 | { 1299 | "name": "sebastian/recursion-context", 1300 | "version": "1.0.2", 1301 | "source": { 1302 | "type": "git", 1303 | "url": "https://github.com/sebastianbergmann/recursion-context.git", 1304 | "reference": "913401df809e99e4f47b27cdd781f4a258d58791" 1305 | }, 1306 | "dist": { 1307 | "type": "zip", 1308 | "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", 1309 | "reference": "913401df809e99e4f47b27cdd781f4a258d58791", 1310 | "shasum": "" 1311 | }, 1312 | "require": { 1313 | "php": ">=5.3.3" 1314 | }, 1315 | "require-dev": { 1316 | "phpunit/phpunit": "~4.4" 1317 | }, 1318 | "type": "library", 1319 | "extra": { 1320 | "branch-alias": { 1321 | "dev-master": "1.0.x-dev" 1322 | } 1323 | }, 1324 | "autoload": { 1325 | "classmap": [ 1326 | "src/" 1327 | ] 1328 | }, 1329 | "notification-url": "https://packagist.org/downloads/", 1330 | "license": [ 1331 | "BSD-3-Clause" 1332 | ], 1333 | "authors": [ 1334 | { 1335 | "name": "Jeff Welch", 1336 | "email": "whatthejeff@gmail.com" 1337 | }, 1338 | { 1339 | "name": "Sebastian Bergmann", 1340 | "email": "sebastian@phpunit.de" 1341 | }, 1342 | { 1343 | "name": "Adam Harvey", 1344 | "email": "aharvey@php.net" 1345 | } 1346 | ], 1347 | "description": "Provides functionality to recursively process PHP variables", 1348 | "homepage": "http://www.github.com/sebastianbergmann/recursion-context", 1349 | "time": "2015-11-11 19:50:13" 1350 | }, 1351 | { 1352 | "name": "sebastian/resource-operations", 1353 | "version": "1.0.0", 1354 | "source": { 1355 | "type": "git", 1356 | "url": "https://github.com/sebastianbergmann/resource-operations.git", 1357 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" 1358 | }, 1359 | "dist": { 1360 | "type": "zip", 1361 | "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1362 | "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", 1363 | "shasum": "" 1364 | }, 1365 | "require": { 1366 | "php": ">=5.6.0" 1367 | }, 1368 | "type": "library", 1369 | "extra": { 1370 | "branch-alias": { 1371 | "dev-master": "1.0.x-dev" 1372 | } 1373 | }, 1374 | "autoload": { 1375 | "classmap": [ 1376 | "src/" 1377 | ] 1378 | }, 1379 | "notification-url": "https://packagist.org/downloads/", 1380 | "license": [ 1381 | "BSD-3-Clause" 1382 | ], 1383 | "authors": [ 1384 | { 1385 | "name": "Sebastian Bergmann", 1386 | "email": "sebastian@phpunit.de" 1387 | } 1388 | ], 1389 | "description": "Provides a list of PHP built-in functions that operate on resources", 1390 | "homepage": "https://www.github.com/sebastianbergmann/resource-operations", 1391 | "time": "2015-07-28 20:34:47" 1392 | }, 1393 | { 1394 | "name": "sebastian/version", 1395 | "version": "2.0.0", 1396 | "source": { 1397 | "type": "git", 1398 | "url": "https://github.com/sebastianbergmann/version.git", 1399 | "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5" 1400 | }, 1401 | "dist": { 1402 | "type": "zip", 1403 | "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", 1404 | "reference": "c829badbd8fdf16a0bad8aa7fa7971c029f1b9c5", 1405 | "shasum": "" 1406 | }, 1407 | "require": { 1408 | "php": ">=5.6" 1409 | }, 1410 | "type": "library", 1411 | "extra": { 1412 | "branch-alias": { 1413 | "dev-master": "2.0.x-dev" 1414 | } 1415 | }, 1416 | "autoload": { 1417 | "classmap": [ 1418 | "src/" 1419 | ] 1420 | }, 1421 | "notification-url": "https://packagist.org/downloads/", 1422 | "license": [ 1423 | "BSD-3-Clause" 1424 | ], 1425 | "authors": [ 1426 | { 1427 | "name": "Sebastian Bergmann", 1428 | "email": "sebastian@phpunit.de", 1429 | "role": "lead" 1430 | } 1431 | ], 1432 | "description": "Library that helps with managing the version number of Git-hosted PHP projects", 1433 | "homepage": "https://github.com/sebastianbergmann/version", 1434 | "time": "2016-02-04 12:56:52" 1435 | }, 1436 | { 1437 | "name": "symfony/yaml", 1438 | "version": "v3.1.0", 1439 | "source": { 1440 | "type": "git", 1441 | "url": "https://github.com/symfony/yaml.git", 1442 | "reference": "eca51b7b65eb9be6af88ad7cc91685f1556f5c9a" 1443 | }, 1444 | "dist": { 1445 | "type": "zip", 1446 | "url": "https://api.github.com/repos/symfony/yaml/zipball/eca51b7b65eb9be6af88ad7cc91685f1556f5c9a", 1447 | "reference": "eca51b7b65eb9be6af88ad7cc91685f1556f5c9a", 1448 | "shasum": "" 1449 | }, 1450 | "require": { 1451 | "php": ">=5.5.9" 1452 | }, 1453 | "type": "library", 1454 | "extra": { 1455 | "branch-alias": { 1456 | "dev-master": "3.1-dev" 1457 | } 1458 | }, 1459 | "autoload": { 1460 | "psr-4": { 1461 | "Symfony\\Component\\Yaml\\": "" 1462 | }, 1463 | "exclude-from-classmap": [ 1464 | "/Tests/" 1465 | ] 1466 | }, 1467 | "notification-url": "https://packagist.org/downloads/", 1468 | "license": [ 1469 | "MIT" 1470 | ], 1471 | "authors": [ 1472 | { 1473 | "name": "Fabien Potencier", 1474 | "email": "fabien@symfony.com" 1475 | }, 1476 | { 1477 | "name": "Symfony Community", 1478 | "homepage": "https://symfony.com/contributors" 1479 | } 1480 | ], 1481 | "description": "Symfony Yaml Component", 1482 | "homepage": "https://symfony.com", 1483 | "time": "2016-05-26 21:46:24" 1484 | } 1485 | ], 1486 | "aliases": [], 1487 | "minimum-stability": "stable", 1488 | "stability-flags": [], 1489 | "prefer-stable": false, 1490 | "prefer-lowest": false, 1491 | "platform": { 1492 | "php": ">=5.5" 1493 | }, 1494 | "platform-dev": [] 1495 | } 1496 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | tests 7 | 8 | 9 | 10 | 11 | src 12 | 13 | src/ 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Client.php: -------------------------------------------------------------------------------- 1 | guzzleClient = $client; 22 | } 23 | 24 | /** 25 | * add your server api key here 26 | * read how to obtain an api key here: https://firebase.google.com/docs/server/setup#prerequisites 27 | * 28 | * @param string $apiKey 29 | * 30 | * @return \sngrl\PhpFirebaseCloudMessaging\Client 31 | */ 32 | public function setApiKey($apiKey) 33 | { 34 | $this->apiKey = $apiKey; 35 | return $this; 36 | } 37 | 38 | /** 39 | * people can overwrite the api url with a proxy server url of their own 40 | * 41 | * @param string $url 42 | * 43 | * @return \sngrl\PhpFirebaseCloudMessaging\Client 44 | */ 45 | public function setProxyApiUrl($url) 46 | { 47 | $this->proxyApiUrl = $url; 48 | return $this; 49 | } 50 | 51 | /** 52 | * sends your notification to the google servers and returns a guzzle repsonse object 53 | * containing their answer. 54 | * 55 | * @param Message $message 56 | * 57 | * @return \Psr\Http\Message\ResponseInterface 58 | * @throws \GuzzleHttp\Exception\RequestException 59 | */ 60 | public function send(Message $message) 61 | { 62 | return $this->guzzleClient->post( 63 | $this->getApiUrl(), 64 | [ 65 | 'headers' => [ 66 | 'Authorization' => sprintf('key=%s', $this->apiKey), 67 | 'Content-Type' => 'application/json' 68 | ], 69 | 'body' => json_encode($message) 70 | ] 71 | ); 72 | } 73 | 74 | /** 75 | * @param integer $topic_id 76 | * @param array|string $recipients_tokens 77 | * 78 | * @return \Psr\Http\Message\ResponseInterface 79 | */ 80 | public function addTopicSubscription($topic_id, $recipients_tokens) 81 | { 82 | return $this->processTopicSubscription($topic_id, $recipients_tokens, self::DEFAULT_TOPIC_ADD_SUBSCRIPTION_API_URL); 83 | } 84 | 85 | 86 | /** 87 | * @param integer $topic_id 88 | * @param array|string $recipients_tokens 89 | * 90 | * @return \Psr\Http\Message\ResponseInterface 91 | */ 92 | public function removeTopicSubscription($topic_id, $recipients_tokens) 93 | { 94 | return $this->processTopicSubscription($topic_id, $recipients_tokens, self::DEFAULT_TOPIC_REMOVE_SUBSCRIPTION_API_URL); 95 | } 96 | 97 | 98 | /** 99 | * @param integer $topic_id 100 | * @param array|string $recipients_tokens 101 | * @param string $url 102 | * 103 | * @return \Psr\Http\Message\ResponseInterface 104 | */ 105 | protected function processTopicSubscription($topic_id, $recipients_tokens, $url) 106 | { 107 | if (!is_array($recipients_tokens)) 108 | $recipients_tokens = [$recipients_tokens]; 109 | 110 | return $this->guzzleClient->post( 111 | $url, 112 | [ 113 | 'headers' => [ 114 | 'Authorization' => sprintf('key=%s', $this->apiKey), 115 | 'Content-Type' => 'application/json' 116 | ], 117 | 'body' => json_encode([ 118 | 'to' => '/topics/' . $topic_id, 119 | 'registration_tokens' => $recipients_tokens, 120 | ]) 121 | ] 122 | ); 123 | } 124 | 125 | 126 | private function getApiUrl() 127 | { 128 | return isset($this->proxyApiUrl) ? $this->proxyApiUrl : self::DEFAULT_API_URL; 129 | } 130 | } -------------------------------------------------------------------------------- /src/ClientInterface.php: -------------------------------------------------------------------------------- 1 | jsonData = []; 31 | } 32 | 33 | /** 34 | * where should the message go 35 | * 36 | * @param Recipient $recipient 37 | * 38 | * @return \sngrl\PhpFirebaseCloudMessaging\Message 39 | */ 40 | public function addRecipient(Recipient $recipient) 41 | { 42 | $this->recipients[] = $recipient; 43 | 44 | if (!isset($this->recipientType)) { 45 | $this->recipientType = get_class($recipient); 46 | } 47 | if ($this->recipientType !== get_class($recipient)) { 48 | throw new \InvalidArgumentException('mixed recepient types are not supported by FCM'); 49 | } 50 | 51 | return $this; 52 | } 53 | 54 | public function setNotification(Notification $notification) 55 | { 56 | $this->notification = $notification; 57 | return $this; 58 | } 59 | 60 | public function setCollapseKey($collapseKey) 61 | { 62 | $this->collapseKey = $collapseKey; 63 | return $this; 64 | } 65 | 66 | public function setPriority($priority) 67 | { 68 | $this->priority = $priority; 69 | return $this; 70 | } 71 | 72 | public function setData(array $data) 73 | { 74 | $this->data = $data; 75 | return $this; 76 | } 77 | 78 | /** 79 | * Specify a condition pattern when sending to combinations of topics 80 | * https://firebase.google.com/docs/cloud-messaging/topic-messaging#sending_topic_messages_from_the_server 81 | * 82 | * Examples: 83 | * "%s && %s" > Send to devices subscribed to topic 1 and topic 2 84 | * "%s && (%s || %s)" > Send to devices subscribed to topic 1 and topic 2 or 3 85 | * 86 | * @param string $condition 87 | * @return $this 88 | */ 89 | public function setCondition($condition) { 90 | $this->condition = $condition; 91 | return $this; 92 | } 93 | 94 | /** 95 | * Set root message data via key 96 | * 97 | * @param string $key 98 | * @param mixed $value 99 | * @return $this 100 | */ 101 | public function setJsonKey($key, $value) { 102 | $this->jsonData[$key] = $value; 103 | return $this; 104 | } 105 | 106 | /** 107 | * Unset root message data via key 108 | * 109 | * @param string $key 110 | * @return $this 111 | */ 112 | public function unsetJsonKey($key) { 113 | unset($this->jsonData[$key]); 114 | return $this; 115 | } 116 | 117 | /** 118 | * Get root message data via key 119 | * 120 | * @param string $key 121 | * @return mixed 122 | */ 123 | public function getJsonKey($key) { 124 | return $this->jsonData[$key]; 125 | } 126 | 127 | /** 128 | * Get root message data 129 | * 130 | * @return array 131 | */ 132 | public function getJsonData() { 133 | return $this->jsonData; 134 | } 135 | 136 | /** 137 | * Set root message data 138 | * 139 | * @param array $array 140 | * @return $this 141 | */ 142 | public function setJsonData($array) { 143 | $this->jsonData = $array; 144 | return $this; 145 | } 146 | 147 | 148 | public function setDelayWhileIdle($value) 149 | { 150 | $this->setJsonKey('delay_while_idle', (bool)$value); 151 | return $this; 152 | } 153 | 154 | public function setTimeToLive($value) 155 | { 156 | $this->setJsonKey('time_to_live', (int)$value); 157 | return $this; 158 | } 159 | 160 | public function jsonSerialize() 161 | { 162 | $jsonData = $this->jsonData; 163 | 164 | if (empty($this->recipients)) { 165 | throw new \UnexpectedValueException('Message must have at least one recipient'); 166 | } 167 | 168 | if (count($this->recipients) == 1) { 169 | $jsonData['to'] = $this->createTarget(); 170 | } elseif ($this->recipientType == Device::class) { 171 | $jsonData['registration_ids'] = $this->createTarget(); 172 | } else { 173 | $jsonData['condition'] = $this->createTarget(); 174 | } 175 | 176 | if ($this->collapseKey) { 177 | $jsonData['collapse_key'] = $this->collapseKey; 178 | } 179 | if ($this->data) { 180 | $jsonData['data'] = $this->data; 181 | } 182 | if ($this->priority) { 183 | $jsonData['priority'] = $this->priority; 184 | } 185 | if ($this->notification) { 186 | $jsonData['notification'] = $this->notification; 187 | } 188 | 189 | return $jsonData; 190 | } 191 | 192 | private function createTarget() 193 | { 194 | $recipientCount = count($this->recipients); 195 | 196 | switch ($this->recipientType) { 197 | 198 | case Topic::class: 199 | 200 | if ($recipientCount == 1) { 201 | return sprintf('/topics/%s', current($this->recipients)->getName()); 202 | 203 | } else if ($recipientCount > self::MAX_TOPICS) { 204 | throw new \OutOfRangeException(sprintf('Message topic limit exceeded. Firebase supports a maximum of %u topics.', self::MAX_TOPICS)); 205 | 206 | } else if (!$this->condition) { 207 | throw new \InvalidArgumentException('Missing message condition. You must specify a condition pattern when sending to combinations of topics.'); 208 | 209 | } else if ($recipientCount != substr_count($this->condition, '%s')) { 210 | throw new \UnexpectedValueException('The number of message topics must match the number of occurrences of "%s" in the condition pattern.'); 211 | 212 | } else { 213 | $names = []; 214 | foreach ($this->recipients as $recipient) { 215 | $names[] = vsprintf("'%s' in topics", $recipient->getName()); 216 | } 217 | return vsprintf($this->condition, $names); 218 | } 219 | break; 220 | 221 | case Device::class: 222 | 223 | if ($recipientCount == 1) { 224 | return current($this->recipients)->getToken(); 225 | 226 | } else if ($recipientCount > self::MAX_DEVICES) { 227 | throw new \OutOfRangeException(sprintf('Message device limit exceeded. Firebase supports a maximum of %u devices.', self::MAX_DEVICES)); 228 | 229 | } else { 230 | $ids = []; 231 | foreach ($this->recipients as $recipient) { 232 | $ids[] = $recipient->getToken(); 233 | } 234 | return $ids; 235 | } 236 | break; 237 | 238 | default: 239 | break; 240 | } 241 | return null; 242 | } 243 | } -------------------------------------------------------------------------------- /src/Notification.php: -------------------------------------------------------------------------------- 1 | title = $title; 22 | if ($body) 23 | $this->body = $body; 24 | parent::__construct(); 25 | } 26 | 27 | public function setTitle($title) 28 | { 29 | $this->title = $title; 30 | return $this; 31 | } 32 | 33 | public function setBody($body) 34 | { 35 | $this->body = $body; 36 | return $this; 37 | } 38 | 39 | /** 40 | * iOS only, will add smal red bubbles indicating the number of notifications to your apps icon 41 | * 42 | * @param integer $badge 43 | * @return $this 44 | */ 45 | public function setBadge($badge) 46 | { 47 | $this->badge = $badge; 48 | return $this; 49 | } 50 | 51 | /** 52 | * android only, set the name of your drawable resource as string 53 | * 54 | * @param string $icon 55 | * @return $this 56 | */ 57 | public function setIcon($icon) 58 | { 59 | $this->icon = $icon; 60 | return $this; 61 | } 62 | 63 | public function setClickAction($actionName) 64 | { 65 | $this->clickAction = $actionName; 66 | return $this; 67 | } 68 | 69 | public function setSound($sound) 70 | { 71 | $this->sound = $sound; 72 | return $this; 73 | } 74 | 75 | public function setTag($tag) 76 | { 77 | $this->tag = $tag; 78 | return $this; 79 | } 80 | 81 | public function setContentAvailable($content_available) 82 | { 83 | $this->content_available = $content_available; 84 | return $this; 85 | } 86 | 87 | public function jsonSerialize() 88 | { 89 | $jsonData = $this->getJsonData(); 90 | if ($this->title) { 91 | $jsonData['title'] = $this->title; 92 | } 93 | if ($this->body) { 94 | $jsonData['body'] = $this->body; 95 | } 96 | if ($this->badge) { 97 | $jsonData['badge'] = $this->badge; 98 | } 99 | if ($this->icon) { 100 | $jsonData['icon'] = $this->icon; 101 | } 102 | if ($this->clickAction) { 103 | $jsonData['click_action'] = $this->clickAction; 104 | } 105 | if ($this->sound) { 106 | $jsonData['sound'] = $this->sound; 107 | } 108 | if ($this->tag) { 109 | $jsonData['tag'] = $this->tag; 110 | } 111 | if ($this->content_available) { 112 | $jsonData['content_available'] = $this->content_available; 113 | } 114 | return $jsonData; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/Recipient/Device.php: -------------------------------------------------------------------------------- 1 | token = $token; 11 | return $this; 12 | } 13 | 14 | public function getToken() 15 | { 16 | return $this->token; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Recipient/Recipient.php: -------------------------------------------------------------------------------- 1 | to = $to; 11 | return $this; 12 | } 13 | 14 | public function toJson() 15 | { 16 | return $this->to; 17 | } 18 | } -------------------------------------------------------------------------------- /src/Recipient/Topic.php: -------------------------------------------------------------------------------- 1 | name = $name; 11 | return $this; 12 | } 13 | 14 | public function getName() 15 | { 16 | return $this->name; 17 | } 18 | } -------------------------------------------------------------------------------- /tests/ClientTest.php: -------------------------------------------------------------------------------- 1 | fixture = new Client(); 19 | } 20 | 21 | public function testSendConstruesValidJsonForNotificationWithTopic() 22 | { 23 | $apiKey = 'key'; 24 | $headers = array( 25 | 'Authorization' => sprintf('key=%s', $apiKey), 26 | 'Content-Type' => 'application/json' 27 | ); 28 | 29 | $guzzle = \Mockery::mock(\GuzzleHttp\Client::class); 30 | $guzzle->shouldReceive('post') 31 | ->once() 32 | ->with(Client::DEFAULT_API_URL, array('headers' => $headers, 'body' => '{"to":"\\/topics\\/test"}')) 33 | ->andReturn(\Mockery::mock(Response::class)); 34 | 35 | $this->fixture->injectGuzzleHttpClient($guzzle); 36 | $this->fixture->setApiKey($apiKey); 37 | 38 | $message = new Message(); 39 | $message->addRecipient(new Topic('test')); 40 | 41 | $this->fixture->send($message); 42 | } 43 | } -------------------------------------------------------------------------------- /tests/MessageTest.php: -------------------------------------------------------------------------------- 1 | fixture = new Message(); 18 | } 19 | 20 | public function testThrowsExceptionWhenDifferentRecepientTypesAreRegistered() 21 | { 22 | $this->setExpectedException(\InvalidArgumentException::class); 23 | $this->fixture->addRecipient(new Topic('breaking-news')) 24 | ->addRecipient(new Recipient()); 25 | } 26 | 27 | public function testThrowsExceptionWhenNoRecepientWasAdded() 28 | { 29 | $this->setExpectedException(\UnexpectedValueException::class); 30 | $this->fixture->jsonSerialize(); 31 | } 32 | 33 | public function testThrowsExceptionWhenMultipleTopicsWereGiven() 34 | { 35 | $this->setExpectedException(\UnexpectedValueException::class); 36 | $this->fixture->addRecipient(new Topic('breaking-news')) 37 | ->addRecipient(new Topic('another topic')); 38 | 39 | $this->fixture->jsonSerialize(); 40 | } 41 | 42 | public function testJsonEncodeWorksOnTopicRecipients() 43 | { 44 | $body = '{"to":"\/topics\/breaking-news","notification":{"title":"test","body":"a nice testing notification"}}'; 45 | 46 | $notification = new Notification('test', 'a nice testing notification'); 47 | $message = new Message(); 48 | $message->setNotification($notification); 49 | 50 | $message->addRecipient(new Topic('breaking-news')); 51 | $this->assertSame( 52 | $body, 53 | json_encode($message) 54 | ); 55 | } 56 | 57 | public function testJsonEncodeWorksOnDeviceRecipients() 58 | { 59 | $body = '{"to":"deviceId","notification":{"title":"test","body":"a nice testing notification"}}'; 60 | 61 | $notification = new Notification('test', 'a nice testing notification'); 62 | $message = new Message(); 63 | $message->setNotification($notification); 64 | 65 | $message->addRecipient(new Device('deviceId')); 66 | $this->assertSame( 67 | $body, 68 | json_encode($message) 69 | ); 70 | } 71 | } -------------------------------------------------------------------------------- /tests/NotificationTest.php: -------------------------------------------------------------------------------- 1 | fixture = new Notification('foo', 'bar'); 14 | } 15 | 16 | public function testJsonSerializeWithMinimalConfigurations() 17 | { 18 | $this->assertEquals(array('title' => 'foo', 'body' =>'bar'), $this->fixture->jsonSerialize()); 19 | } 20 | 21 | public function testJsonSerializeWithBadge() 22 | { 23 | $this->fixture->setBadge(1); 24 | $this->assertEquals(array('title' => 'foo', 'body' =>'bar', 'badge' => 1), $this->fixture->jsonSerialize()); 25 | } 26 | 27 | public function testJsonSerializeWithIcon() 28 | { 29 | $this->fixture->setIcon('name'); 30 | $this->assertEquals(array('title' => 'foo', 'body' =>'bar', 'icon' => 'name'), $this->fixture->jsonSerialize()); 31 | } 32 | 33 | public function testJsonSerializeWithContentAvailable() 34 | { 35 | $this->fixture->setContentAvailable(true); 36 | $this->assertEquals(array('title' => 'foo', 'body' =>'bar', 'content_available' => true), $this->fixture->jsonSerialize()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/PhpFirebaseCloudMessagingTestCase.php: -------------------------------------------------------------------------------- 1 |