Skip to content

Commit

Permalink
StyleCI diff changes implemented.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhartman committed Nov 17, 2019
1 parent c45c868 commit 96bec1a
Show file tree
Hide file tree
Showing 31 changed files with 73 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateInvoicesTableForCashierFastspring extends Migration
*/
public function up()
{
Schema::create('invoices', function(Blueprint $table) {
Schema::create('invoices', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('fastspring_id')->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateSubscriptionPeriodsTableForCashierFastspring extends Migration
*/
public function up()
{
Schema::create('subscription_periods', function(Blueprint $table) {
Schema::create('subscription_periods', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('subscription_id');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CreateSubscriptionsTableForCashierFastspring extends Migration
*/
public function up()
{
Schema::create('subscriptions', function(Blueprint $table) {
Schema::create('subscriptions', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('name');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UpgradeUserTableForCashierFastspring extends Migration
*/
public function up()
{
Schema::table('users', function($table) {
Schema::table('users', function ($table) {
$table->string('fastspring_id')->nullable();
$table->string('company')->nullable();
$table->string('phone')->nullable();
Expand All @@ -29,7 +29,7 @@ public function up()
*/
public function down()
{
Schema::table('users', function(Blueprint $table) {
Schema::table('users', function (Blueprint $table) {
$table->dropColumn(['fastspring_id', 'company', 'phone', 'language', 'country']);
});
}
Expand Down
15 changes: 8 additions & 7 deletions src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring;

use Exception;
use TwentyTwoDigital\CashierFastspring\Exceptions\NotImplementedException;
use TwentyTwoDigital\CashierFastspring\Fastspring\Fastspring;
use Exception;

/**
* Billable trait.
*
* {@inheritDoc}
* {@inheritdoc}
*/
trait Billable
{
Expand Down Expand Up @@ -151,7 +152,7 @@ public function subscribedToPlan($plans, $subscription = 'default')
{
$subscription = $this->subscription($subscription);

if (!$subscription || !$subscription->valid()) {
if (! $subscription || ! $subscription->valid()) {
return false;
}

Expand All @@ -173,7 +174,7 @@ public function subscribedToPlan($plans, $subscription = 'default')
*/
public function onPlan($plan)
{
return !is_null($this->subscriptions->first(function ($value) use ($plan) {
return ! is_null($this->subscriptions->first(function ($value) use ($plan) {
return $value->plan === $plan && $value->valid();
}));
}
Expand All @@ -185,7 +186,7 @@ public function onPlan($plan)
*/
public function hasFastspringId()
{
return !is_null($this->fastspring_id);
return ! is_null($this->fastspring_id);
}

/**
Expand Down Expand Up @@ -244,7 +245,7 @@ public function createAsFastspringCustomer(array $options = [])
*/
public function updateAsFastspringCustomer(array $options = [])
{
if (!$this->hasFastspringId()) {
if (! $this->hasFastspringId()) {
throw new Exception('User has no fastspring_id');
}

Expand Down Expand Up @@ -277,7 +278,7 @@ public function asFastspringCustomer()
{
// check the fastspring_id first
// if there is non, no need to try
if (!$this->hasFastspringId()) {
if (! $this->hasFastspringId()) {
throw new Exception('User has no fastspring_id');
}

Expand Down
3 changes: 2 additions & 1 deletion src/CashierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
* @copyright 2019 22 Digital
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring;

use Illuminate\Support\ServiceProvider;

/**
* This class describes the Laravel Cashier Service Provider.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class CashierServiceProvider extends ServiceProvider
{
Expand Down
1 change: 1 addition & 0 deletions src/Exceptions/NotImplementedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @copyright 2019 22 Digital
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Exceptions;

use BadMethodCallException;
Expand Down
3 changes: 1 addition & 2 deletions src/Fastspring/ApiClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@
* @license MIT
* @see https://docs.fastspring.com/integrating-with-fastspring/fastspring-api
*/

namespace TwentyTwoDigital\CashierFastspring\Fastspring;

use GuzzleHttp\Client;

/**
* This class describes an api client.
*
* {@inheritDoc}
*/
class ApiClient
{
Expand Down
5 changes: 2 additions & 3 deletions src/Fastspring/Fastspring.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
* @license MIT
* @see https://docs.fastspring.com/integrating-with-fastspring/fastspring-api
*/

namespace TwentyTwoDigital\CashierFastspring\Fastspring;

/**
* This class describes the Fastspring implementation.
*
* {@inheritDoc}
*/
class Fastspring
{
Expand All @@ -39,7 +38,7 @@ class Fastspring
*/
public static function __callStatic($method, $parameters)
{
if (!self::$instance) {
if (! self::$instance) {
$username = (getenv('FASTSPRING_USERNAME') ?: config('services.fastspring.username'));
$password = (getenv('FASTSPRING_PASSWORD') ?: config('services.fastspring.password'));

Expand Down
9 changes: 5 additions & 4 deletions src/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Http\Controllers;

use TwentyTwoDigital\CashierFastspring\Events;
use TwentyTwoDigital\CashierFastspring\Fastspring\Fastspring;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Str;
use Log;
use Symfony\Component\HttpFoundation\Response;
use TwentyTwoDigital\CashierFastspring\Events;
use TwentyTwoDigital\CashierFastspring\Fastspring\Fastspring;

/**
* Controls the data flow into a webhook object and updates the view
* whenever data changes.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class WebhookController extends Controller
{
Expand Down Expand Up @@ -83,7 +84,7 @@ public function handleWebhook(Request $request)
try {
// check if the related event classes are exist
// there may be not handled events
if (!class_exists($categoryEvent) || !class_exists($activityEvent)) {
if (! class_exists($categoryEvent) || ! class_exists($activityEvent)) {
throw new Exception('There is no event for '.$event['type']);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring;

use Illuminate\Database\Eloquent\Model;

/**
* This class describes an invoice.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class Invoice extends Model
{
Expand Down
3 changes: 1 addition & 2 deletions src/Listeners/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Listeners;

/**
* This class describes a base.
*
* {@inheritDoc}
*/
class Base
{
Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/OrderCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Listeners;

use TwentyTwoDigital\CashierFastspring\Events;
Expand All @@ -22,7 +23,7 @@
* Note: "order.completed" event is works just at creation for subscription products.
* IMPORTANT: This class handles expansion enabled webhooks
*
* {@inheritDoc}
* {@inheritdoc}
*/
class OrderCompleted extends Base
{
Expand Down
4 changes: 2 additions & 2 deletions src/Listeners/SubscriptionActivated.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*
* IMPORTANT: This class handles expansion enabled webhooks.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class SubscriptionActivated extends Base
{
Expand Down Expand Up @@ -57,7 +57,7 @@ public function handle(Events\SubscriptionActivated $event)

$subscription = $user->subscription();

if (!$subscription) {
if (! $subscription) {
$subscription = new Subscription();
$subscription->user_id = $user->id;
$subscription->name = $subscriptionName;
Expand Down
7 changes: 4 additions & 3 deletions src/Listeners/SubscriptionChargeCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Listeners;

use Carbon\Carbon;
use Illuminate\Support\Str;
use TwentyTwoDigital\CashierFastspring\Events;
use TwentyTwoDigital\CashierFastspring\Invoice;
use TwentyTwoDigital\CashierFastspring\Subscription;
use Carbon\Carbon;
use Illuminate\Support\Str;

/**
* This class is a listener for subscription charge completed events.
Expand All @@ -23,7 +24,7 @@
*
* IMPORTANT: This class handles expansion enabled webhooks.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class SubscriptionChargeCompleted extends Base
{
Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/SubscriptionDeactivated.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Listeners;

use TwentyTwoDigital\CashierFastspring\Events;
Expand All @@ -17,7 +18,7 @@
* This class is a listener for subscription deactivation events.
* It deactivated fastspring subscription and create another local, free one.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class SubscriptionDeactivated extends Base
{
Expand Down
3 changes: 2 additions & 1 deletion src/Listeners/SubscriptionStateChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring\Listeners;

use TwentyTwoDigital\CashierFastspring\Events;
Expand All @@ -22,7 +23,7 @@
*
* IMPORTANT: This class handles expansion enabled webhooks.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class SubscriptionStateChanged extends Base
{
Expand Down
11 changes: 6 additions & 5 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@
* @license MIT
* @since v0.1
*/

namespace TwentyTwoDigital\CashierFastspring;

use TwentyTwoDigital\CashierFastspring\Fastspring\Fastspring;
use Carbon\Carbon;
use Exception;
use Illuminate\Database\Eloquent\Model;
use LogicException;
use TwentyTwoDigital\CashierFastspring\Fastspring\Fastspring;

/**
* This class describes a subscription.
*
* {@inheritDoc}
* {@inheritdoc}
*/
class Subscription extends Model
{
Expand Down Expand Up @@ -229,7 +230,7 @@ protected function createPeriodLocally()
];

$lastPeriod = SubscriptionPeriod::firstOrCreate($subscriptionPeriodData);
} while (!($today->greaterThanOrEqualTo($lastPeriod->start_date)
} while (! ($today->greaterThanOrEqualTo($lastPeriod->start_date)
&& $today->lessThanOrEqualTo($lastPeriod->end_date)
));

Expand Down Expand Up @@ -259,7 +260,7 @@ public function owner()
*/
public function valid()
{
return !$this->deactivated();
return ! $this->deactivated();
}

/**
Expand Down Expand Up @@ -498,7 +499,7 @@ public function cancelNow()
*/
public function resume()
{
if (!$this->onGracePeriod()) {
if (! $this->onGracePeriod()) {
throw new LogicException('Unable to resume subscription that is not within grace period or not canceled.');
}

Expand Down
Loading

0 comments on commit 96bec1a

Please sign in to comment.