From b439ce4663ea26a3b38975479bfd8f72dfe13115 Mon Sep 17 00:00:00 2001 From: "LAPTOP-PLVVCJSK\\Rodrigo" Date: Tue, 20 Mar 2018 21:31:37 +0000 Subject: [PATCH 01/23] simple api call using cUrl --- .gitignore | 1 + demo.php | 12 +++++++++ nbproject/project.properties | 7 +++++ nbproject/project.xml | 9 +++++++ src/AbstractApi.php | 51 ++++++++++++++++++++++++++++++++++++ src/Api.php | 44 +++++++++++++++++++++++++++++++ src/InterfaceApi.php | 21 +++++++++++++++ 7 files changed, 145 insertions(+) create mode 100644 demo.php create mode 100644 nbproject/project.properties create mode 100644 nbproject/project.xml create mode 100644 src/AbstractApi.php create mode 100644 src/Api.php create mode 100644 src/InterfaceApi.php diff --git a/.gitignore b/.gitignore index a4854be..431ae6b 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ Homestead.json # Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer .rocketeer/ +/nbproject/private/ \ No newline at end of file diff --git a/demo.php b/demo.php new file mode 100644 index 0000000..58de659 --- /dev/null +++ b/demo.php @@ -0,0 +1,12 @@ + 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi , 'limit'=> 50)); +$api->getData(); \ No newline at end of file diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..76f6f91 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_56 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..513cacb --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + News-API-php + + + diff --git a/src/AbstractApi.php b/src/AbstractApi.php new file mode 100644 index 0000000..396ca7b --- /dev/null +++ b/src/AbstractApi.php @@ -0,0 +1,51 @@ + $this->url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "UTF-8", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_HTTPHEADER => array( + "Cache-Control: no-cache", + ), + )); + + $response = curl_exec($curl); + $err = curl_error($curl); + + curl_close($curl); + + $this->setData($response); + + if ($err) { + throw new \Exception("cURL Error #:" . $err); + } + } + + public function getData() { + return $this->data; + } + + private function setData($data) { + $this->data = json_decode($data); + } + +} diff --git a/src/Api.php b/src/Api.php new file mode 100644 index 0000000..06851d3 --- /dev/null +++ b/src/Api.php @@ -0,0 +1,44 @@ +url = URL . $type . "?{$uri}"; + + //execute + $this->call(); + + } + + +} diff --git a/src/InterfaceApi.php b/src/InterfaceApi.php new file mode 100644 index 0000000..4e404ac --- /dev/null +++ b/src/InterfaceApi.php @@ -0,0 +1,21 @@ + Date: Tue, 20 Mar 2018 21:40:35 +0000 Subject: [PATCH 02/23] add composer --- .gitignore | 3 ++- composer.json | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 composer.json diff --git a/.gitignore b/.gitignore index 431ae6b..db7da77 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,5 @@ Homestead.json # Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer .rocketeer/ -/nbproject/private/ \ No newline at end of file +/nbproject/private/ +/nbproject/ \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..55cb492 --- /dev/null +++ b/composer.json @@ -0,0 +1,17 @@ +{ + "name": "rmanara/news-api-php", + "description": "Api call for newFeed", + "type": "library", + "authors": [ + { + "name": "Rodrigo Manara", + "email": "me@rodrigomanara.co.uk" + } + ], + "minimum-stability": "stable", + "autoload": { + "psr-4": { + "NewsApi\\": "src/" + } + } +} From 725d331455c33cf3673beba002e2246ced4dfc7f Mon Sep 17 00:00:00 2001 From: "LAPTOP-PLVVCJSK\\Rodrigo" Date: Tue, 20 Mar 2018 21:44:43 +0000 Subject: [PATCH 03/23] remove extra para demo --- demo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demo.php b/demo.php index 58de659..e418db5 100644 --- a/demo.php +++ b/demo.php @@ -8,5 +8,5 @@ require_once './src/Api.php'; -$api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi , 'limit'=> 50)); +$api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); $api->getData(); \ No newline at end of file From d4ceac64f48dc464653ba5f3812d5e22f26ae173 Mon Sep 17 00:00:00 2001 From: "LAPTOP-PLVVCJSK\\Rodrigo" Date: Tue, 20 Mar 2018 21:46:31 +0000 Subject: [PATCH 04/23] remove ide config --- nbproject/project.properties | 7 ------- nbproject/project.xml | 9 --------- 2 files changed, 16 deletions(-) delete mode 100644 nbproject/project.properties delete mode 100644 nbproject/project.xml diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 76f6f91..0000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,7 +0,0 @@ -include.path=${php.global.include.path} -php.version=PHP_56 -source.encoding=UTF-8 -src.dir=. -tags.asp=false -tags.short=false -web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 513cacb..0000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - org.netbeans.modules.php.project - - - News-API-php - - - From 93e309b4bacabbb6e81a1628cba0ade769b1e7d6 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 20 Mar 2018 21:47:41 +0000 Subject: [PATCH 05/23] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6b84375..35d3284 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # News API SDK for PHP -Coming soon... this is where our officially supported SDK for PHP is going to live. -*** -## Developers... we need you! -We need some help fleshing out this repo. If you're a PHP dev with experience building Composer-compatible libraries and web API wrappers, we're offering a reward of $250 to help us get started. For more info please email support@newsapi.org, or dive right in and send us a pull request. +require_once './src/Api.php'; + +$api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); +$api->getData(); From d6974f9461ff9a1f83563344371323af1919de1e Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 20 Mar 2018 21:51:09 +0000 Subject: [PATCH 06/23] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 35d3284..8b039c0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -# News API SDK for PHP +# News API SDK for PHP +Search through millions of articles from over 30,000 large and small news sources and blogs. This includes breaking news as well as lesser articles. + +# Example require_once './src/Api.php'; From 873fa00338a906101b3bf8190955b41f04f77bc0 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 20 Mar 2018 21:53:29 +0000 Subject: [PATCH 07/23] Update README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8b039c0..196258f 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,6 @@ require_once './src/Api.php'; $api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); $api->getData(); + +# Composer install +composer require rmanara/news-api-php From 08e4fe2236537e88ae70ec30835f755c9101e1fe Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 20 Mar 2018 21:56:16 +0000 Subject: [PATCH 08/23] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 196258f..feb8ca7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # News API SDK for PHP Search through millions of articles from over 30,000 large and small news sources and blogs. This includes breaking news as well as lesser articles. +find out more about it: [documentation](https://newsapi.org/docs/) # Example @@ -9,5 +10,8 @@ require_once './src/Api.php'; $api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); $api->getData(); + # Composer install -composer require rmanara/news-api-php + +> composer require rmanara/news-api-php + From bc2e16b5f0cb1607c76cc8f286c0c71958437627 Mon Sep 17 00:00:00 2001 From: "LAPTOP-PLVVCJSK\\Rodrigo" Date: Wed, 21 Mar 2018 07:27:44 +0000 Subject: [PATCH 09/23] add changes and fix issue on interface --- demo.php | 9 ++++++--- src/AbstractApi.php | 7 +++---- src/Api.php | 6 +++--- src/InterfaceApi.php | 5 ++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/demo.php b/demo.php index e418db5..5d83644 100644 --- a/demo.php +++ b/demo.php @@ -6,7 +6,10 @@ * and open the template in the editor. */ -require_once './src/Api.php'; +require_once './vendor/autoload.php'; -$api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); -$api->getData(); \ No newline at end of file +$api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => '')); +$data = $api->getData(); + + +var_dump($data); \ No newline at end of file diff --git a/src/AbstractApi.php b/src/AbstractApi.php index 396ca7b..fadf9a7 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -8,15 +8,14 @@ * @author Rodrigo */ class AbstractApi implements InterfaceApi { + - public $url; - - protected function call() { + protected function call($url) { $curl = curl_init(); curl_setopt_array($curl, array( - CURLOPT_URL => $this->url, + CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "UTF-8", CURLOPT_MAXREDIRS => 10, diff --git a/src/Api.php b/src/Api.php index 06851d3..9571c00 100644 --- a/src/Api.php +++ b/src/Api.php @@ -30,13 +30,13 @@ class Api extends AbstractApi { * @param type $query * @param type TOP_HEADLINE | EVERYTHING | SOURCES */ - public function __construct($query = array() , $type = TOP_HEADLINE ) { + public function __construct($query = array() , $type = self::TOP_HEADLINE ) { $uri = http_build_query($query); - $this->url = URL . $type . "?{$uri}"; + $url = self::URL . $type . "?{$uri}"; //execute - $this->call(); + $this->call($url); } diff --git a/src/InterfaceApi.php b/src/InterfaceApi.php index 4e404ac..7416616 100644 --- a/src/InterfaceApi.php +++ b/src/InterfaceApi.php @@ -13,9 +13,8 @@ * * @author Rodrigo */ -class InterfaceApi { +interface InterfaceApi { - - public function call(); + public function getData(); } From b5f81e716b6aff7fcc5bee4c22894c3b8738dc46 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Wed, 21 Mar 2018 17:20:29 +0000 Subject: [PATCH 10/23] add validation on apikey --- composer.json | 3 + composer.lock | 1472 +++++++++++++++++++++++++++++++++++++++++++ src/AbstractApi.php | 49 +- src/Api.php | 28 +- 4 files changed, 1529 insertions(+), 23 deletions(-) create mode 100644 composer.lock diff --git a/composer.json b/composer.json index 55cb492..31f33a3 100644 --- a/composer.json +++ b/composer.json @@ -13,5 +13,8 @@ "psr-4": { "NewsApi\\": "src/" } + }, + "require-dev": { + "phpunit/phpunit": "^7.0" } } diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..9bc0d66 --- /dev/null +++ b/composer.lock @@ -0,0 +1,1472 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "content-hash": "a66cec00524c9d0c182e1eddfe6a0876", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "^6.2.3", + "squizlabs/php_codesniffer": "^3.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2017-07-22T11:58:36+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19T19:58:43+00:00" + }, + { + "name": "phar-io/manifest", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/manifest.git", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/2df402786ab5368a0169091f61a7c1e0eb6852d0", + "reference": "2df402786ab5368a0169091f61a7c1e0eb6852d0", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-phar": "*", + "phar-io/version": "^1.0.1", + "php": "^5.6 || ^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "time": "2017-03-05T18:14:27+00:00" + }, + { + "name": "phar-io/version", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/a70c0ced4be299a63d32fa96d9281d03e94041df", + "reference": "a70c0ced4be299a63d32fa96d9281d03e94041df", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "time": "2017-03-05T17:38:23+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "4.3.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", + "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "shasum": "" + }, + "require": { + "php": "^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "doctrine/instantiator": "~1.0.5", + "mockery/mockery": "^1.0", + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-30T07:14:17+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.7.5", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2018-02-19T10:16:54+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f8ca4b604baf23dab89d87773c28cc07405189ba", + "reference": "f8ca4b604baf23dab89d87773c28cc07405189ba", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^7.1", + "phpunit/php-file-iterator": "^1.4.2", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-token-stream": "^3.0", + "sebastian/code-unit-reverse-lookup": "^1.0.1", + "sebastian/environment": "^3.0", + "sebastian/version": "^2.0.1", + "theseer/tokenizer": "^1.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "suggest": { + "ext-xdebug": "^2.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2018-02-02T07:01:41+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2017-11-27T13:52:08+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", + "reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2018-02-01T13:07:23+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "reference": "21ad88bbba7c3d93530d93994e0a33cd45f02ace", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2018-02-01T13:16:43+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "7.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "e2f8aa21bc54b6ba218bdd4f9e0dac1e9bc3b4e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e2f8aa21bc54b6ba218bdd4f9e0dac1e9bc3b4e9", + "reference": "e2f8aa21bc54b6ba218bdd4f9e0dac1e9bc3b4e9", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "^1.6.1", + "phar-io/manifest": "^1.0.1", + "phar-io/version": "^1.0", + "php": "^7.1", + "phpspec/prophecy": "^1.7", + "phpunit/php-code-coverage": "^6.0", + "phpunit/php-file-iterator": "^1.4.3", + "phpunit/php-text-template": "^1.2.1", + "phpunit/php-timer": "^2.0", + "phpunit/phpunit-mock-objects": "^6.0", + "sebastian/comparator": "^2.1", + "sebastian/diff": "^3.0", + "sebastian/environment": "^3.1", + "sebastian/exporter": "^3.1", + "sebastian/global-state": "^2.0", + "sebastian/object-enumerator": "^3.0.3", + "sebastian/resource-operations": "^1.0", + "sebastian/version": "^2.0.1" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "^2.0" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "7.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2018-02-26T07:03:12+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "6.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/e3249dedc2d99259ccae6affbc2684eac37c2e53", + "reference": "e3249dedc2d99259ccae6affbc2684eac37c2e53", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.5", + "php": "^7.1", + "phpunit/php-text-template": "^1.2.1", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2018-02-15T05:27:38+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/34369daee48eafb2651bea869b4b15d75ccc35f9", + "reference": "34369daee48eafb2651bea869b4b15d75ccc35f9", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/diff": "^2.0 || ^3.0", + "sebastian/exporter": "^3.1" + }, + "require-dev": { + "phpunit/phpunit": "^6.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2018-02-01T13:46:46+00:00" + }, + { + "name": "sebastian/diff", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/e09160918c66281713f1c324c1f4c4c3037ba1e8", + "reference": "e09160918c66281713f1c324c1f4c4c3037ba1e8", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "require-dev": { + "phpunit/phpunit": "^7.0", + "symfony/process": "^2 || ^3.3 || ^4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "time": "2018-02-01T13:45:15+00:00" + }, + { + "name": "sebastian/environment", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "reference": "cd0871b3975fb7fc44d11314fd1ee20925fce4f5", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2017-07-01T08:51:00+00:00" + }, + { + "name": "sebastian/exporter", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/234199f4528de6d12aaa58b612e98f7d36adb937", + "reference": "234199f4528de6d12aaa58b612e98f7d36adb937", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2017-04-03T13:19:02+00:00" + }, + { + "name": "sebastian/global-state", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "reference": "e8ba02eed7bbbb9e59e43dedd3dddeff4a56b0c4", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2017-04-27T15:39:26+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "reference": "7cfd9e65d11ffb5af41198476395774d4c8a84c5", + "shasum": "" + }, + "require": { + "php": "^7.0", + "sebastian/object-reflector": "^1.1.1", + "sebastian/recursion-context": "^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-08-03T12:35:26+00:00" + }, + { + "name": "sebastian/object-reflector", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "773f97c67f28de00d397be301821b06708fca0be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/773f97c67f28de00d397be301821b06708fca0be", + "reference": "773f97c67f28de00d397be301821b06708fca0be", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "time": "2017-03-29T09:07:27+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "reference": "5b0cd723502bac3b006cbf3dbf7a1e3fcefe4fa8", + "shasum": "" + }, + "require": { + "php": "^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2017-03-03T06:23:57+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "theseer/tokenizer", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.0" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "time": "2017-04-07T12:08:54+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.3.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a", + "reference": "0df1908962e7a3071564e857d86874dad1ef204a", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2018-01-29T19:49:41+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/src/AbstractApi.php b/src/AbstractApi.php index fadf9a7..c86319d 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -8,10 +8,17 @@ * @author Rodrigo */ class AbstractApi implements InterfaceApi { - + + private $data; + + const NEWSAPI = ''; + const URL = 'https://newsapi.org/v2/'; + const TOP_HEADLINE = 'top-headlines'; + const EVERYTHING = 'everything'; + const SOURCES = 'sources'; protected function call($url) { - + $curl = curl_init(); curl_setopt_array($curl, array( @@ -23,7 +30,7 @@ protected function call($url) { CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => array( - "Cache-Control: no-cache", + "Cache-Control: no-cache", ), )); @@ -43,8 +50,40 @@ public function getData() { return $this->data; } - private function setData($data) { - $this->data = json_decode($data); + protected function setData($data, $encode = true) { + + if ($encode) { + $this->data = json_decode($data); + } else { + + foreach($data as $key => $value){ + $this->data[$key] = $value; + } + + } + } + + /** + * + * @param type $query + * @return type + */ + protected function validate($query) { + + + $validate = (in_array('apiKey', $query) && isset($query['apiKey']) && !empty($query['apiKey'])) ? false : true; + if ($validate) { + $obj = ['error' => ['apikey' => 'missing apikey']]; + $this->setData($obj, false); + } + + $validate = (isset($query['type']) && (self::TOP_HEADLINE == $query['type'] || self::SOURCES == $query['type'] || self::EVERYTHING == $query['type'])) ? false : true; + if ($validate) { + $obj = ['error' => ['type' => 'type is not correct']]; + $this->setData($obj, false); + } + + return $validate; } } diff --git a/src/Api.php b/src/Api.php index 9571c00..6e9395b 100644 --- a/src/Api.php +++ b/src/Api.php @@ -15,30 +15,22 @@ */ class Api extends AbstractApi { -//put your code here - - - const NEWSAPI = ''; - const URL = 'https://newsapi.org/v2/'; - const TOP_HEADLINE = 'top-headlines'; - const EVERYTHING = 'everything'; - const SOURCES = 'sources'; - - /** * * @param type $query * @param type TOP_HEADLINE | EVERYTHING | SOURCES */ - public function __construct($query = array() , $type = self::TOP_HEADLINE ) { - + public function __construct($query = array(), $type = self::TOP_HEADLINE) { + $uri = http_build_query($query); - $url = self::URL . $type . "?{$uri}"; - - //execute - $this->call($url); + $url = self::URL . $type . "?{$uri}"; + + if ($this->validate($query) && $this->validate(['type' => $type])) { + //execute + $this->call($url); + } } - - + + } From 5afc1ee564cd3087c3f041e859cc7fdd21101012 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 08:05:36 +0100 Subject: [PATCH 11/23] Create .travis.yml --- .travis.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..01ae7ac --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: php +php: + - '7.3' +sudo: required +before_script: + - composer install --prefer-source +notifications: + email: + - me@rodrigomanara.co.uk From 2a7d187e618bb81edc4f0c2f98f00b72103b9664 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 08:06:20 +0100 Subject: [PATCH 12/23] Create testApi.php --- test/testApi.php | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 test/testApi.php diff --git a/test/testApi.php b/test/testApi.php new file mode 100644 index 0000000..4989bea --- /dev/null +++ b/test/testApi.php @@ -0,0 +1,2 @@ + Date: Tue, 23 Jul 2019 08:07:21 +0100 Subject: [PATCH 13/23] Create phpunit.xml --- phpunit.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..59c2d17 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,20 @@ + + + + + ./test/ + + + + From 04a6ca7e101237bd0d635658ef2f03a8cc2a48e4 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 08:12:11 +0100 Subject: [PATCH 14/23] Update phpunit.xml --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 59c2d17..572e602 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ Date: Tue, 23 Jul 2019 10:01:16 +0100 Subject: [PATCH 15/23] add changes on test --- src/AbstractApi.php | 29 ++++++++++++++++++++-------- src/Api.php | 3 +-- test/testApi.php | 46 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/src/AbstractApi.php b/src/AbstractApi.php index c86319d..ef96d2f 100644 --- a/src/AbstractApi.php +++ b/src/AbstractApi.php @@ -11,7 +11,7 @@ class AbstractApi implements InterfaceApi { private $data; - const NEWSAPI = ''; + const NEWSAPI = 'cec26d4a3d9d4aeaa7684ec614575317'; const URL = 'https://newsapi.org/v2/'; const TOP_HEADLINE = 'top-headlines'; const EVERYTHING = 'everything'; @@ -68,17 +68,30 @@ protected function setData($data, $encode = true) { * @param type $query * @return type */ - protected function validate($query) { + protected function validateQuery($query) { - - $validate = (in_array('apiKey', $query) && isset($query['apiKey']) && !empty($query['apiKey'])) ? false : true; - if ($validate) { + $validate = (key_exists('apiKey', $query) && isset($query['apiKey']) && !empty($query['apiKey'])) ? true : false; + if (!$validate) { $obj = ['error' => ['apikey' => 'missing apikey']]; $this->setData($obj, false); - } + } + + + return $validate; + } + + + /** + * + * @param type $query + * @return type + */ + protected function validateType($query) { + + - $validate = (isset($query['type']) && (self::TOP_HEADLINE == $query['type'] || self::SOURCES == $query['type'] || self::EVERYTHING == $query['type'])) ? false : true; - if ($validate) { + $validate = (isset($query['type']) && ((self::TOP_HEADLINE == $query['type'] || self::SOURCES == $query['type'] || self::EVERYTHING == $query['type']))) ? true : false; + if (!$validate) { $obj = ['error' => ['type' => 'type is not correct']]; $this->setData($obj, false); } diff --git a/src/Api.php b/src/Api.php index 6e9395b..35be9c3 100644 --- a/src/Api.php +++ b/src/Api.php @@ -24,9 +24,8 @@ public function __construct($query = array(), $type = self::TOP_HEADLINE) { $uri = http_build_query($query); $url = self::URL . $type . "?{$uri}"; - - if ($this->validate($query) && $this->validate(['type' => $type])) { + if ($this->validateQuery($query) && $this->validateType(['type' => $type])) { //execute $this->call($url); } diff --git a/test/testApi.php b/test/testApi.php index 4989bea..fbba31b 100644 --- a/test/testApi.php +++ b/test/testApi.php @@ -1,2 +1,46 @@ -getData(); + $this->assertEquals($data['error']['apikey'], 'missing apikey'); + } + /** + * + * @return void + */ + public function testwithKeywithoutrequiredParametersApiCall(): void { + $new = new Api([ + 'apiKey' => Api::NEWSAPI + ]); + $data = $new->getData(); + + + $this->assertEquals($data->status, 'error'); + } + /** + * + * @return void + */ + public function testwithKeywithrequiredParametersApiCall(): void { + $new = new Api([ + 'apiKey' => Api::NEWSAPI, + 'language' => 'pt' + ]); + $data = $new->getData(); + + $this->assertEquals($data->status, 'ok'); + } + +} From 0cce3fa3aee112cdf03705191e3e81462ac5c124 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 10:06:27 +0100 Subject: [PATCH 16/23] fix path --- phpunit.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 572e602..6f5879e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,6 @@ Date: Tue, 23 Jul 2019 10:10:19 +0100 Subject: [PATCH 17/23] fix path --- phpunit.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 6f5879e..b1ffe60 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,6 +1,5 @@ Date: Tue, 23 Jul 2019 10:17:08 +0100 Subject: [PATCH 18/23] fix phpunit --- phpunit.xml | 2 +- test/testApi.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index b1ffe60..7ef1bca 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -12,7 +12,7 @@ verbose="true"> - ./test/ + ./test/testApi.php diff --git a/test/testApi.php b/test/testApi.php index fbba31b..8f04bb0 100644 --- a/test/testApi.php +++ b/test/testApi.php @@ -6,7 +6,7 @@ use NewsApi\Api; -final class NewsApiTest extends PHPUnit\Framework\TestCase { +final class testApi extends PHPUnit\Framework\TestCase { /** * * @return void From dbf6e1ac9f701808e6f97e88473a7697beade651 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 10:18:44 +0100 Subject: [PATCH 19/23] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index feb8ca7..df870f8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/rodrigomanara/News-API-php.svg?branch=master)](https://travis-ci.org/rodrigomanara/News-API-php.svg?branch=master) + # News API SDK for PHP Search through millions of articles from over 30,000 large and small news sources and blogs. This includes breaking news as well as lesser articles. From f2b222c7b1ca208fc81c6ee0319b1ef053a10399 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 10:20:12 +0100 Subject: [PATCH 20/23] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index df870f8..0c99429 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ find out more about it: [documentation](https://newsapi.org/docs/) # Example -require_once './src/Api.php'; +require_once __DIR__ . '/../vendor/autoload.php'; $api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); $api->getData(); From a857fe30454d0c4e2d1d2494c8421a4cabeda517 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 10:20:59 +0100 Subject: [PATCH 21/23] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0c99429..6cf1871 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,13 @@ Search through millions of articles from over 30,000 large and small news source find out more about it: [documentation](https://newsapi.org/docs/) # Example - +``` require_once __DIR__ . '/../vendor/autoload.php'; $api = new \NewsApi\Api( array('q' => 'Reino Unido' , 'language'=> 'pt' , 'apiKey' => newsapi)); -$api->getData(); +$api->getData(); +``` # Composer install From 2e81ef6818284c20eef2b0d3a104b2ccb92842d0 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Tue, 23 Jul 2019 11:57:21 +0100 Subject: [PATCH 22/23] Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 6cf1871..e981105 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@ [![Build Status](https://travis-ci.org/rodrigomanara/News-API-php.svg?branch=master)](https://travis-ci.org/rodrigomanara/News-API-php.svg?branch=master) +[![Latest Stable Version](https://poser.pugx.org/rmanara/News-API-php/v/stable)](https://packagist.org/packages/rmanara/News-API-php) +[![License](https://poser.pugx.org/rmanara/News-API-php/license)](https://packagist.org/packages/rmanara/News-API-php) +[![Latest Unstable Version](https://poser.pugx.org/rmanara/News-API-php/v/unstable)](https://packagist.org/packages/rmanara/News-API-php) + + # News API SDK for PHP From 3689e86f395b67245b4e568a4b845d9fb8746836 Mon Sep 17 00:00:00 2001 From: Rodrigo Manara Date: Sat, 21 Dec 2019 10:26:08 +0000 Subject: [PATCH 23/23] Create php.yml --- .github/workflows/php.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/php.yml diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..8e856b8 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,23 @@ +name: PHP Composer + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-suggest + + # Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit" + # Docs: https://getcomposer.org/doc/articles/scripts.md + + # - name: Run test suite + # run: composer run-script test