Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
sebdesign committed Sep 14, 2017
1 parent 2c757c0 commit 37a58eb
Show file tree
Hide file tree
Showing 15 changed files with 44 additions and 30 deletions.
4 changes: 4 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
preset: laravel

enabled:
- alpha_ordered_imports

disabled:
- single_class_element_per_statement
- length_ordered_imports
3 changes: 3 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Viva Payments for Laravel

[![Latest Version on Packagist](https://img.shields.io/packagist/v/sebdesign/laravel-viva-payments.svg?style=flat-square)](https://packagist.org/packages/sebdesign/laravel-viva-payments)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
[![Build Status](https://travis-ci.org/sebdesign/laravel-viva-payments.svg)](https://travis-ci.org/sebdesign/laravel-viva-payments)
[![Quality Score](https://img.shields.io/scrutinizer/g/sebdesign/laravel-viva-payments.svg?style=flat-square)](https://scrutinizer-ci.com/g/sebdesign/laravel-viva-payments)

[![VivaPayments logo](https://camo.githubusercontent.com/7f0b41d204f5c27c416a83fa0bc8d1d1e45cf495/68747470733a2f2f7777772e766976617061796d656e74732e636f6d2f436f6e74656e742f696d672f6c6f676f2e737667 "VivaPayments logo")](https://www.vivapayments.com/)

Expand Down
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function patch($url, array $options = [])
/**
* Make a DELETE request.
*
* @param string $endpoint
* @param string $url
* @param array $options
* @return object
*/
Expand Down
25 changes: 18 additions & 7 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public function get($id)
/**
* Get the transactions for an order code.
*
* @param int $orderCode
* @param int $ordercode
* @return array
*/
public function getByOrder($ordercode)
Expand All @@ -171,9 +171,7 @@ public function getByOrder($ordercode)
*/
public function getByDate($date)
{
if ($date instanceof \DateTimeInterface) {
$date = $date->format('Y-m-d');
}
$date = $this->formatDate($date);

$response = $this->client->get(self::ENDPOINT, [
\GuzzleHttp\RequestOptions::QUERY => compact('date'),
Expand All @@ -190,9 +188,7 @@ public function getByDate($date)
*/
public function getByClearanceDate($clearancedate)
{
if ($clearancedate instanceof \DateTimeInterface) {
$clearancedate = $clearancedate->format('Y-m-d');
}
$clearancedate = $this->formatDate($clearancedate);

$response = $this->client->get(self::ENDPOINT, [
\GuzzleHttp\RequestOptions::QUERY => compact('clearancedate'),
Expand All @@ -201,6 +197,21 @@ public function getByClearanceDate($clearancedate)
return $response->Transactions;
}

/**
* Format a date object to string.
*
* @param \DateTimeInterface|string $date
* @return string
*/
protected function formatDate($date)
{
if ($date instanceof \DateTimeInterface) {
return $date->format('Y-m-d');
}

return $date;
}

/**
* Cancel or refund a payment.
*
Expand Down
7 changes: 4 additions & 3 deletions src/VivaPaymentsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,19 @@ public function register()
);

$this->app->singleton(Client::class, function ($app) {
return new Client($this->bootGuzzleClient());
return new Client($this->bootGuzzleClient($app));
});
}

/**
* Instantiate the Guzzlehttp client.
*
* @param \Illuminate\Contracts\Foundation\Application $app
* @return GuzzleHttp\Client
*/
protected function bootGuzzleClient()
protected function bootGuzzleClient($app)
{
$config = $this->app['config']->get('services.viva');
$config = $app['config']->get('services.viva');

return new GuzzleClient([
'base_uri' => $this->getUrl($config['environment']),
Expand Down
6 changes: 3 additions & 3 deletions src/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,21 @@ protected function handleTransaction(Request $request)
*
* @param \Illuminate\Http\Request $request
*/
protected abstract function handleCreateTransaction(Request $request);
abstract protected function handleCreateTransaction(Request $request);

/**
* Handle a Refund Transaction event notification.
*
* @param \Illuminate\Http\Request $request
*/
protected abstract function handleRefundTransaction(Request $request);
abstract protected function handleRefundTransaction(Request $request);

/**
* Handle any other type of event notification.
*
* @param \Illuminate\Http\Request $request
*/
protected abstract function handleEventNotification(Request $request);
abstract protected function handleEventNotification(Request $request);

/**
* Verify a webhook.
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Illuminate\Support\Carbon;
use Sebdesign\VivaPayments\Card;
use Sebdesign\VivaPayments\Order;
use Sebdesign\VivaPayments\Transaction;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\Transaction;

class TransactionTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Sebdesign\VivaPayments\Test\Functional;

use Sebdesign\VivaPayments\Webhook;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\Webhook;

class WebhookTest extends TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Sebdesign\VivaPayments\Test;

use GuzzleHttp\HandlerStack;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Client as GuzzleClient;
use Sebdesign\VivaPayments\Card;
use Sebdesign\VivaPayments\Client;
use Sebdesign\VivaPayments\VivaPaymentsServiceProvider;
Expand Down
4 changes: 0 additions & 4 deletions tests/Unit/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

namespace Sebdesign\VivaPayments\Test\Unit;

use GuzzleHttp\Psr7\Response;
use InvalidArgumentException;
use Sebdesign\VivaPayments\Client;
use Sebdesign\VivaPayments\Order;
use Sebdesign\VivaPayments\VivaException;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\VivaPaymentsServiceProvider;

class ServiceProviderTest extends TestCase
{

/**
* @test
* @group unit
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace Sebdesign\VivaPayments\Test\Unit;

use GuzzleHttp\Psr7\Response;
use InvalidArgumentException;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\Psr7\Response;
use Sebdesign\VivaPayments\Client;
use Sebdesign\VivaPayments\Order;
use Sebdesign\VivaPayments\VivaException;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\VivaException;

class ClientTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/OrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Sebdesign\VivaPayments\Test\Unit;

use Sebdesign\VivaPayments\Order;
use Sebdesign\VivaPayments\Client;
use Sebdesign\VivaPayments\Order;
use Sebdesign\VivaPayments\Test\TestCase;

class OrderTest extends TestCase
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Sebdesign\VivaPayments\Test\Unit;

use Illuminate\Support\Carbon;
use DateTime;
use Sebdesign\VivaPayments\Transaction;
use Illuminate\Support\Carbon;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\Transaction;

class TransactionTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/WebhookControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Sebdesign\VivaPayments\Test\Unit;

use Illuminate\Http\Request;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\Webhook;
use Sebdesign\VivaPayments\WebhookController;
use Sebdesign\VivaPayments\Test\TestCase;

class WebhookControllerTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/WebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Sebdesign\VivaPayments\Test\Unit;

use Sebdesign\VivaPayments\Webhook;
use Sebdesign\VivaPayments\Test\TestCase;
use Sebdesign\VivaPayments\Webhook;

class WebhookTest extends TestCase
{
Expand Down

0 comments on commit 37a58eb

Please sign in to comment.