Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Commit

Permalink
Skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
percymamedy committed May 23, 2016
1 parent 7965510 commit b81d3f6
Show file tree
Hide file tree
Showing 7 changed files with 176 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
}
],
"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/"
}
}
}
17 changes: 17 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false">
<testsuites>
<testsuite name="WatsonBridge">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
103 changes: 103 additions & 0 deletions src/Bridge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace FindBrok\WatsonBridge;

use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request;

/**
* Class Bridge
*
* @package FindBrok\WatsonBridge
*/
class Bridge
{
/**
* API Username
*
* @var string
*/
protected $username;

/**
* API password
*
* @var string
*/
protected $password;

/**
* API Endpoint for making request
*
* @var string
*/
protected $endpoint;

/**
* Guzzle http client for performing API request
*
* @var \GuzzleHttp\Client
*/
protected $client;

/**
* The request object
*
* @var \GuzzleHttp\Psr7\Request
*/
protected $request;

/**
* Create a new instance of bridge
*
* @param string $username
* @param string $password
* @param string $endpoint
*/
public function __construct($username = null, $password = null, $endpoint = null)
{
//Set Username, Password and Endpoint
$this->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;
}
}
9 changes: 9 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

/**
* Class TestCase
*/
class TestCase extends PHPUnit_Framework_TestCase
{

}

0 comments on commit b81d3f6

Please sign in to comment.