From b81d3f651709e082380120167811b08eb2341ef2 Mon Sep 17 00:00:00 2001 From: Percy Mamedy Date: Mon, 23 May 2016 23:19:22 +0400 Subject: [PATCH] Skeleton --- .gitignore | 1 + .travis.yml | 14 ++++++ README.md | 5 ++- composer.json | 29 +++++++++++++ phpunit.xml | 17 ++++++++ src/Bridge.php | 103 +++++++++++++++++++++++++++++++++++++++++++++ tests/TestCase.php | 9 ++++ 7 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 src/Bridge.php create mode 100644 tests/TestCase.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57872d0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/vendor/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..22af9e1 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: php + +php: + - '5.5' + - '5.6' + - '7.0' + +before_script: + - composer self-update + +install: + - composer install --prefer-source --no-interaction --dev + +script: vendor/bin/phpunit diff --git a/README.md b/README.md index ea5de55..ef25050 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ -# php-watson-api-bridge -A PHP wrapper for IBM Watson API +# PHP IBM Watson API Bridge + +A simple PHP wrapper for IBM Watson API diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..2c355a5 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "findbrok/php-watson-api-bridge", + "description": "A simple PHP Wrapper around IBM Watson API", + "keywords": ["php", "ibm", "watson", "api", "bridge"], + "license": "MIT", + "authors": [ + { + "name": "Percy Mamedy", + "email": "percymamedy@gmail.com" + } + ], + "require": { + "php": ">=5.5.0", + "guzzlehttp/guzzle": "~5.3|~6.0|~6.2" + }, + "require-dev": { + "fzaninotto/faker": "~1.4", + "phpunit/phpunit": "~4.0", + "mockery/mockery": "0.9.*" + }, + "autoload": { + "classmap": [ + "tests/TestCase.php" + ], + "psr-4": { + "FindBrok\\WatsonBridge\\" : "src/" + } + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..a18bd9f --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,17 @@ + + + + + ./tests/ + + + diff --git a/src/Bridge.php b/src/Bridge.php new file mode 100644 index 0000000..b03ac32 --- /dev/null +++ b/src/Bridge.php @@ -0,0 +1,103 @@ +username = $username; + $this->password = $password; + $this->endpoint = $endpoint; + //Set HttpClient + $this->setClient(); + } + + /** + * Return the authorization for making request + * + * @return array + */ + public function getAuth() + { + //Return access authorization + return [ + 'auth' => [$this->username, $this->password] + ]; + } + + /** + * Creates the http client + * + * @return void + */ + private function setClient() + { + //Create client using API endpoint + $this->client = new Client([ + 'base_uri' => $this->endpoint, + ]); + } + + /** + * Return the Http client instance + * + * @return \GuzzleHttp\Client + */ + public function getClient() + { + //Return client + return $this->client; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php new file mode 100644 index 0000000..b4054fc --- /dev/null +++ b/tests/TestCase.php @@ -0,0 +1,9 @@ +