Skip to content

Commit

Permalink
StyleCi fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
darthsoup committed May 24, 2018
1 parent 5d6b46e commit fdd319e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 28 deletions.
4 changes: 2 additions & 2 deletions config/whmcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

'api' => [
'identifier' => 'YOUR_API_IDENTIFIER',
'secret' => 'YOUR_API_SECRET'
'secret' => 'YOUR_API_SECRET',
],

'password' => [
Expand All @@ -46,5 +46,5 @@
|
*/

'responsetype' => 'json'
'responsetype' => 'json',
];
4 changes: 2 additions & 2 deletions src/Adapter/ConnectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace DarthSoup\Whmcs\Adapter;

/**
* Interface ConnectorInterface
* Interface ConnectorInterface.
*/
interface ConnectorInterface
{
public function connect(array $config);
}
}
18 changes: 8 additions & 10 deletions src/Adapter/GuzzleHttpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace DarthSoup\Whmcs\Adapter;

use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use Illuminate\Support\Arr;
use InvalidArgumentException;
use GuzzleHttp\ClientInterface;

/**
* Class GuzzleHttpAdapter
* Class GuzzleHttpAdapter.
*/
class GuzzleHttpAdapter implements ConnectorInterface
{
Expand Down Expand Up @@ -41,29 +41,27 @@ public function connect(array $config)
private function getConfig($config)
{
if ('api' === $config['auth_type']) {

$credentials = Arr::get($config, $config['auth_type']);

if (!array_key_exists('identifier', $credentials) || empty($credentials['identifier'])) {
if (! array_key_exists('identifier', $credentials) || empty($credentials['identifier'])) {
throw new InvalidArgumentException('The guzzlehttp connector requires configuration.');
}

if (!array_key_exists('secret', $credentials) || empty($credentials['secret'])) {
if (! array_key_exists('secret', $credentials) || empty($credentials['secret'])) {
throw new InvalidArgumentException('The guzzlehttp connector requires configuration.');
}

return $config;
}

if ('password' === $config['auth_type']) {

$credentials = Arr::get($config, $config['auth_type']);

if (!array_key_exists('username', $credentials) || empty($credentials['username'])) {
if (! array_key_exists('username', $credentials) || empty($credentials['username'])) {
throw new InvalidArgumentException('The guzzlehttp connector requires configuration.');
}

if (!array_key_exists('password', $credentials) || empty($credentials['password'])) {
if (! array_key_exists('password', $credentials) || empty($credentials['password'])) {
throw new InvalidArgumentException('The guzzlehttp connector requires configuration.');
}

Expand All @@ -87,12 +85,12 @@ private function getAdapter()
'form_params' => array_merge(
Arr::get($this->config, $this->config['auth_type']),
[
'responsetype' => Arr::get($this->config, 'responsetype', 'json')
'responsetype' => Arr::get($this->config, 'responsetype', 'json'),
]
),
'headers' => [
'User-Agent' => 'Laravel WHMCS API Interface',
]
],
]);
}
}
4 changes: 1 addition & 3 deletions src/Facades/Whmcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
use Illuminate\Support\Facades\Facade;

/**
* Class Whmcs
*
* @package DarthSoup\Whmcs\Facades
* Class Whmcs.
*/
class Whmcs extends Facade
{
Expand Down
5 changes: 3 additions & 2 deletions src/WhmcsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace DarthSoup\Whmcs;

use DarthSoup\Whmcs\Adapter\ConnectorInterface;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Contracts\Config\Repository;
use DarthSoup\Whmcs\Adapter\ConnectorInterface;

/**
* Class WhmcsManager
* Class WhmcsManager.
*/
class WhmcsManager
{
Expand Down Expand Up @@ -61,6 +61,7 @@ protected function execute(string $method, $parameters = [])
return json_decode($response->getBody()->getContents(), true);
} catch (ClientException $ex) {
$response = json_decode($ex->getResponse()->getBody()->getContents(), true);

return $response;
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/WhmcsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace DarthSoup\Whmcs;

use DarthSoup\Whmcs\Adapter\GuzzleHttpAdapter;
use Illuminate\Container\Container;
use Illuminate\Support\ServiceProvider;
use DarthSoup\Whmcs\Adapter\GuzzleHttpAdapter;

/**
* Whmcs ServiceProvider
* Whmcs ServiceProvider.
*/
class WhmcsServiceProvider extends ServiceProvider
{
Expand All @@ -19,7 +19,7 @@ class WhmcsServiceProvider extends ServiceProvider
public function boot()
{
if ($this->isLaravel()) {
$source = dirname(__DIR__) . '/config/whmcs.php';
$source = dirname(__DIR__).'/config/whmcs.php';
$this->publishes([$source => config_path('whmcs.php')]);
$this->mergeConfigFrom($source, 'whmcs');
}
Expand All @@ -38,7 +38,7 @@ public function register()
}

/**
* register Client
* register Client.
*/
public function registerClient()
{
Expand All @@ -49,13 +49,14 @@ public function registerClient()
}

/**
* register Whmcs
* register Whmcs.
*/
public function registerWhmcs()
{
$this->app->singleton('whmcs', function (Container $app) {
$config = $app['config'];
$client = $app['whmcs.client'];

return new WhmcsManager($config, $client);
});
$this->app->alias('whmcs', Whmcs::class);
Expand All @@ -73,10 +74,10 @@ public function provides()
}

/**
* @return boolean
* @return bool
*/
protected function isLaravel()
{
return !preg_match('/lumen/i', $this->app->version());
return ! preg_match('/lumen/i', $this->app->version());
}
}
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ abstract class TestCase extends \Orchestra\Testbench\TestCase
protected function getPackageProviders($app)
{
return [
WhmcsServiceProvider::class
WhmcsServiceProvider::class,
];
}

Expand Down
1 change: 0 additions & 1 deletion tests/WhmcsManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ class WhmcsManagerTest extends TestCase
/** @test */
public function CreateConnection()
{

}
}

0 comments on commit fdd319e

Please sign in to comment.