Skip to content

Commit

Permalink
Final changes to StyleCI which should pass validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhartman committed Nov 18, 2019
1 parent 498436f commit e667874
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 47 deletions.
4 changes: 1 addition & 3 deletions .styleci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,4 @@ finder:
enabled:
- concat_with_spaces
disabled:
- not_operator_with_successor_space
- unary_operator_spaces
- concat_without_spaces
- function_declaration
10 changes: 5 additions & 5 deletions src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,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 @@ -174,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 @@ -186,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 @@ -245,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 @@ -278,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
16 changes: 8 additions & 8 deletions src/CashierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ public function boot()

// publish migrations
$this->publishes([
__DIR__.'/../resources/migrations/create_subscriptions_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations').'/%s_create_subscriptions_table_for_cashier_fastspring.php',
__DIR__ . '/../resources/migrations/create_subscriptions_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations') . '/%s_create_subscriptions_table_for_cashier_fastspring.php',
date('Y_m_d_His', $time)
),
__DIR__.'/../resources/migrations/upgrade_user_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations').'/%s_upgrade_user_table_for_cashier_fastspring.php',
__DIR__ . '/../resources/migrations/upgrade_user_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations') . '/%s_upgrade_user_table_for_cashier_fastspring.php',
date('Y_m_d_His', ++$time)
),
__DIR__.'/../resources/migrations/create_invoices_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations').'/%s_create_invoices_table_for_cashier_fastspring.php',
__DIR__ . '/../resources/migrations/create_invoices_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations') . '/%s_create_invoices_table_for_cashier_fastspring.php',
date('Y_m_d_His', ++$time)
),
__DIR__.'/../resources/migrations/create_subscription_periods_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations').'/%s_create_subscription_periods_table_for_cashier_fastspring.php',
__DIR__ . '/../resources/migrations/create_subscription_periods_table_for_cashier_fastspring.php' => sprintf(
database_path('migrations') . '/%s_create_subscription_periods_table_for_cashier_fastspring.php',
date('Y_m_d_His', ++$time)
),
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Fastspring/Fastspring.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,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
8 changes: 4 additions & 4 deletions src/Http/Controllers/WebhookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public function handleWebhook(Request $request)
// prepare category event class names like OrderAny
$explodedType = explode('.', $event['type']);
$category = array_shift($explodedType);
$categoryEvent = '\TwentyTwoDigital\CashierFastspring\Events\\'.Str::studly($category).'Any';
$categoryEvent = '\TwentyTwoDigital\CashierFastspring\Events\\' . Str::studly($category) . 'Any';

// prepare category event class names like activity
$activity = str_replace('.', ' ', $event['type']);
$activityEvent = '\TwentyTwoDigital\CashierFastspring\Events\\'.Str::studly($activity);
$activityEvent = '\TwentyTwoDigital\CashierFastspring\Events\\' . Str::studly($activity);

// there may be some exceptions on events
// so if anything goes bad its ID won't be added on the successfullEvents
Expand All @@ -84,8 +84,8 @@ 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)) {
throw new Exception('There is no event for '.$event['type']);
if (!class_exists($categoryEvent) || !class_exists($activityEvent)) {
throw new Exception('There is no event for ' . $event['type']);
}

// trigger events
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/SubscriptionActivated.php
Original file line number Diff line number Diff line change
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
2 changes: 1 addition & 1 deletion src/Listeners/SubscriptionChargeCompleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function handle(Events\SubscriptionChargeCompleted $event)
$periodEndDate = $nextDate->subDay()->format('Y-m-d H:i:s');

// yeap, weird way
$methodName = 'sub'.Str::title($subscription->interval_unit).'sNoOverflow';
$methodName = 'sub' . Str::title($subscription->interval_unit) . 'sNoOverflow';
$periodStartDate = $nextDate->$methodName($subscription->interval_length)->addDay()->format('Y-m-d H:i:s');

// fill the model
Expand Down
16 changes: 8 additions & 8 deletions src/Subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected function createPeriodLocally()
break;

default:
throw new Exception('Unexcepted interval unit: '.$subscription->interval_unit);
throw new Exception('Unexcepted interval unit: ' . $subscription->interval_unit);
}

$subscriptionPeriodData = [
Expand All @@ -230,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 @@ -260,7 +260,7 @@ public function owner()
*/
public function valid()
{
return ! $this->deactivated();
return !$this->deactivated();
}

/**
Expand Down Expand Up @@ -436,7 +436,7 @@ public function swap($plan, $prorate, $quantity = 1, $coupons = [])

// else
// TODO: it might be better to create custom exception
throw new Exception('Swap operation failed. Response: '.json_encode($response));
throw new Exception('Swap operation failed. Response: ' . json_encode($response));
}

/**
Expand All @@ -462,7 +462,7 @@ public function cancel()

// else
// TODO: it might be better to create custom exception
throw new Exception('Cancel operation failed. Response: '.json_encode($response));
throw new Exception('Cancel operation failed. Response: ' . json_encode($response));
}

/**
Expand All @@ -486,7 +486,7 @@ public function cancelNow()

// else
// TODO: it might be better to create custom exception
throw new Exception('CancelNow operation failed. Response: '.json_encode($response));
throw new Exception('CancelNow operation failed. Response: ' . json_encode($response));
}

/**
Expand All @@ -499,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 All @@ -520,6 +520,6 @@ public function resume()

// else
// TODO: it might be better to create custom exception
throw new Exception('Resume operation failed. Response: '.json_encode($response));
throw new Exception('Resume operation failed. Response: ' . json_encode($response));
}
}
2 changes: 1 addition & 1 deletion src/SubscriptionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function create()
*/
protected function getFastspringIdOfCustomer()
{
if (! $this->owner->fastspring_id) {
if (!$this->owner->fastspring_id) {
try {
$customer = $this->owner->createAsFastspringCustomer();
} catch (ClientException $e) {
Expand Down
2 changes: 1 addition & 1 deletion tests/CashierFastspringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CashierFastspringTest extends TestCase

public static function setUpBeforeClass()
{
if (file_exists(__DIR__.'/.env')) {
if (file_exists(__DIR__ . '/.env')) {
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/FastspringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FastspringTest extends TestCase

public static function setUpBeforeClass()
{
if (file_exists(__DIR__.'/.env')) {
if (file_exists(__DIR__ . '/.env')) {
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/InvoiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class InvoiceTest extends TestCase

public static function setUpBeforeClass()
{
if (file_exists(__DIR__.'/.env')) {
if (file_exists(__DIR__ . '/.env')) {
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
}
Expand Down
14 changes: 7 additions & 7 deletions tests/ListenersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ListenersTest extends TestCase

public static function setUpBeforeClass()
{
if (file_exists(__DIR__.'/.env')) {
if (file_exists(__DIR__ . '/.env')) {
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public function testSubscriptionDeactivatedListener()
*/
protected function payloadOfSubscriptionCanceled($subscriptionId, $accountId)
{
$template = file_get_contents(__DIR__.'/Payloads/subscription_canceled.json');
$template = file_get_contents(__DIR__ . '/Payloads/subscription_canceled.json');
$jsonString = $this->renderTemplate(
$template,
['subscriptionId' => $subscriptionId, 'accountId' => $accountId]
Expand All @@ -144,15 +144,15 @@ protected function payloadOfSubscriptionCanceled($subscriptionId, $accountId)

protected function payloadOfSubscriptionActivated($accountId)
{
$template = file_get_contents(__DIR__.'/Payloads/subscription_activated.json');
$template = file_get_contents(__DIR__ . '/Payloads/subscription_activated.json');
$jsonString = $this->renderTemplate($template, ['accountId' => $accountId]);

return json_decode($jsonString, true);
}

protected function payloadOfSubscriptionDeactivated($accountId, $subscriptionId)
{
$template = file_get_contents(__DIR__.'/Payloads/subscription_deactivated.json');
$template = file_get_contents(__DIR__ . '/Payloads/subscription_deactivated.json');
$jsonString = $this->renderTemplate($template, [
'accountId' => $accountId,
'subscriptionId' => $subscriptionId,
Expand All @@ -163,7 +163,7 @@ protected function payloadOfSubscriptionDeactivated($accountId, $subscriptionId)

protected function payloadOfSubscriptionChargeCompleted($subscriptionId, $accountId)
{
$template = file_get_contents(__DIR__.'/Payloads/subscription_charge_completed.json');
$template = file_get_contents(__DIR__ . '/Payloads/subscription_charge_completed.json');
$jsonString = $this->renderTemplate(
$template,
['subscriptionId' => $subscriptionId, 'accountId' => $accountId]
Expand All @@ -174,7 +174,7 @@ protected function payloadOfSubscriptionChargeCompleted($subscriptionId, $accoun

protected function payloadOfOrderCompleted($accountId)
{
$template = file_get_contents(__DIR__.'/Payloads/order_completed.json');
$template = file_get_contents(__DIR__ . '/Payloads/order_completed.json');
$jsonString = $this->renderTemplate($template, ['accountId' => $accountId]);

return json_decode($jsonString, true);
Expand All @@ -188,7 +188,7 @@ protected function renderTemplate($template, $data)
$patterns = [];

foreach ($dataKeys as $dataKey) {
$patterns[] = '/{'.$dataKey.'}/';
$patterns[] = '/{' . $dataKey . '}/';
}

return preg_replace($patterns, $replacements, $template);
Expand Down
2 changes: 1 addition & 1 deletion tests/SubscriptionPeriodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SubscriptionPeriodTest extends TestCase

public static function setUpBeforeClass()
{
if (file_exists(__DIR__.'/.env')) {
if (file_exists(__DIR__ . '/.env')) {
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
}
Expand Down
8 changes: 4 additions & 4 deletions tests/WebhookControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class WebhookControllerTest extends TestCase
*/
public static function setUpBeforeClass()
{
if (file_exists(__DIR__.'/.env')) {
if (file_exists(__DIR__ . '/.env')) {
$dotenv = \Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public function testWebhooksEvents()

foreach ($webhookEvents as $key => $webhookEvent) {
$mockEvent = [
'id' => 'id-'.$key,
'id' => 'id-' . $key,
'live' => true,
'processed' => false,
'type' => $webhookEvent,
Expand All @@ -209,11 +209,11 @@ public function testWebhooksEvents()
// prepare category event class names like OrderAny
$explodedType = explode('.', $mockEvent['type']);
$category = array_shift($explodedType);
$categoryEvent = 'TwentyTwoDigital\CashierFastspring\Events\\'.Str::studly($category).'Any';
$categoryEvent = 'TwentyTwoDigital\CashierFastspring\Events\\' . Str::studly($category) . 'Any';

// prepare category event class names like activity
$activity = str_replace('.', ' ', $mockEvent['type']);
$activityEvent = 'TwentyTwoDigital\CashierFastspring\Events\\'.Str::studly($activity);
$activityEvent = 'TwentyTwoDigital\CashierFastspring\Events\\' . Str::studly($activity);

$listenEvents = [
Events\Any::class,
Expand Down

0 comments on commit e667874

Please sign in to comment.