Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervanhooft committed Jan 24, 2025
1 parent 1d44848 commit 0ef360b
Show file tree
Hide file tree
Showing 152 changed files with 437 additions and 875 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/style_with_pint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Fix Code Style

on: [push]

jobs:
lint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.3]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring
coverage: none

- name: Install Pint
run: composer global require laravel/pint

- name: Run Pint
run: pint

- name: Commit linted files
uses: stefanzweifel/git-auto-commit-action@v5
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fail-fast: true
matrix:
os: [ ubuntu-latest ]
php: [8.3, 8.2, 8.1]
php: [8.4, 8.3]
laravel: [ 11.*, 10.* ]
dependency-version: [ prefer-stable ]

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
}
],
"require": {
"php": "^8.2",
"php": "^8.3",
"ext-json": "*",
"ext-intl": "*",
"dompdf/dompdf": "^3.1",
Expand All @@ -42,6 +42,7 @@
"nesbot/carbon": "^3.8"
},
"require-dev": {
"laravel/pint": "^1.20",
"mockery/mockery": "^1.4",
"orchestra/testbench": "^8.0|^9.0",
"phpunit/phpunit": "^10.0"
Expand Down
2 changes: 1 addition & 1 deletion config/cashier_coupons.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* The class responsible for validating and applying the coupon discount.
* Must extend \Cashier\Discount\BaseCouponHandler
*/
//'handler' => '\SomeHandler',
// 'handler' => '\SomeHandler',

/**
* The number of times this coupon will be applied. I.e. If you'd like to prove 6 months discount on a
Expand Down
6 changes: 3 additions & 3 deletions config/cashier_plans.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
'interval' => [
'generator' => AdvancedIntervalGenerator::class,
'value' => 1,
'period' => 'month', /* day, month or year*/
'period' => 'month', /* day, month or year */
'monthOverflow' => true,
],

Expand All @@ -80,10 +80,10 @@
* OrderItem is processed into an OrderItem. You can use this for calculating variable costs a.k.a. metered
* billing. Make sure the preprocessors extend the BaseOrderItemProcessor.
*/
//'order_item_preprocessors' => [
// 'order_item_preprocessors' => [
// ProcessCoupons::class,
// PersistOrderItems::class,
//],
// ],
],
],
];
30 changes: 8 additions & 22 deletions src/Billable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

trait Billable
{
use PopulatesMollieCustomerFields;
use ManagesCharges;
use PopulatesMollieCustomerFields;

/**
* Get all of the subscriptions for the billable model.
Expand All @@ -53,9 +53,9 @@ public function subscription($subscription = 'default')
return $this->subscriptions->sortByDesc(function ($value) {
return $value->created_at->getTimestamp();
})
->first(function ($value) use ($subscription) {
return $value->name === $subscription;
});
->first(function ($value) use ($subscription) {
return $value->name === $subscription;
});
}

/**
Expand Down Expand Up @@ -95,8 +95,6 @@ public function newSubscription($subscription, $plan, $firstPaymentOptions = [])
* Begin creating a new subscription. The customer will always be redirected to Mollie's checkout to make the first
* mandate payment.
*
* @param $subscription
* @param $plan
* @param array $firstPaymentOptions
* @return \Laravel\Cashier\SubscriptionBuilder\FirstPaymentSubscriptionBuilder
*
Expand Down Expand Up @@ -157,7 +155,6 @@ public function mollieCustomerId()
/**
* Create a Mollie customer for the billable model.
*
* @param array $override_options
* @return Customer
*/
public function createAsMollieCustomer(array $override_options = [])
Expand Down Expand Up @@ -261,8 +258,6 @@ public function subscribed($subscription = 'default', $plan = null)

/**
* Determine if the billable model has any active subscription.
*
* @return bool
*/
public function hasActiveSubscription(): bool
{
Expand All @@ -271,8 +266,8 @@ public function hasActiveSubscription(): bool
->whereActive()
->exists();
}

/**
* @param $plans
* @param string $subscription
* @return bool
*/
Expand Down Expand Up @@ -351,7 +346,6 @@ public function hasCredit($currency = null)
/**
* Retrieve the credit balance for the billable model for a specific currency.
*
* @param $currency
* @return \Illuminate\Database\Eloquent\Model
*/
public function credit($currency)
Expand All @@ -371,7 +365,6 @@ public function credit($currency)
/**
* Add a credit amount for the billable model balance.
*
* @param \Money\Money $amount
* @return $this
*/
public function addCredit(Money $amount)
Expand All @@ -384,7 +377,6 @@ public function addCredit(Money $amount)
/**
* Use this model's max amount of credit.
*
* @param \Money\Money $amount
* @return Money
*/
public function maxOutCredit(Money $amount)
Expand Down Expand Up @@ -417,13 +409,11 @@ public function invoices()
/**
* Create an invoice download response.
*
* @param $orderId
* @param null|array $data
* @param string $view
* @param \Dompdf\Options $options
* @return \Symfony\Component\HttpFoundation\Response
*/
public function downloadInvoice($orderId, $data = [], $view = Invoice::DEFAULT_VIEW, Options $options = null)
public function downloadInvoice($orderId, $data = [], $view = Invoice::DEFAULT_VIEW, ?Options $options = null)
{
/** @var Order $order */
$order = $this->orders()->where('id', $orderId)->firstOrFail();
Expand Down Expand Up @@ -507,7 +497,7 @@ public function pendingMollieMandate()
public function validateMollieMandate()
{
if ($this->pendingMollieMandate()) {
throw new MandateIsNotYetFinalizedException();
throw new MandateIsNotYetFinalizedException;
}

if ($this->validMollieMandate()) {
Expand All @@ -526,7 +516,7 @@ public function validateMollieMandate()
*/
public function guardMollieMandate()
{
throw_unless($this->validateMollieMandate(), new InvalidMandateException());
throw_unless($this->validateMollieMandate(), new InvalidMandateException);

return true;
}
Expand Down Expand Up @@ -607,7 +597,6 @@ public function updatePaymentMethod()
/**
* Find an invoice using an order number.
*
* @param $orderNumber
* @return \Laravel\Cashier\Order\Invoice|null
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
Expand All @@ -631,7 +620,6 @@ public function findInvoice($orderNumber)
/**
* Find an invoice using an order number or throw a NotFoundHttpException.
*
* @param $orderNumber
* @return \Laravel\Cashier\Order\Invoice
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Expand All @@ -651,7 +639,6 @@ public function findInvoiceOrFail($orderNumber)
/**
* Find an invoice by order id.
*
* @param $orderId
* @return \Laravel\Cashier\Order\Invoice|null
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
Expand All @@ -673,7 +660,6 @@ public function findInvoiceByOrderId($orderId)
}

/**
* @param $orderId
* @return \Laravel\Cashier\Order\Invoice
*
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
Expand Down
3 changes: 0 additions & 3 deletions src/Cashier.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ public static function usesCurrencyLocale()
/**
* Set the custom currency formatter.
*
* @param callable $callback
* @return void
*/
public static function formatCurrencyUsing(callable $callback)
Expand All @@ -244,7 +243,6 @@ public static function formatCurrencyUsing(callable $callback)
/**
* Format the given amount into a displayable currency.
*
* @param \Money\Money $money
* @return string
*/
public static function formatAmount(Money $money)
Expand Down Expand Up @@ -359,7 +357,6 @@ public static function useRefundItemModel($refundItemModel)
}

/**
* @param \Illuminate\Database\Eloquent\Model $owner
* @return null|string
*/
public static function getLocale(Model $owner)
Expand Down
48 changes: 24 additions & 24 deletions src/CashierServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function boot()
$this->registerResources();

$this->app->resolved(MollieApiClient::class, function (MollieApiClient $mollie) {
return $mollie->addVersionString('MollieLaravelCashier/' . self::PACKAGE_VERSION);
return $mollie->addVersionString('MollieLaravelCashier/'.self::PACKAGE_VERSION);
});

$this->configureCurrency();
Expand Down Expand Up @@ -90,74 +90,74 @@ protected function registerPublishing(): void
protected function registerRoutes(): void
{
if (Cashier::$registersRoutes) {
$this->loadRoutesFrom(__DIR__ . '/../routes/webhooks.php');
$this->loadRoutesFrom(__DIR__.'/../routes/webhooks.php');
}
}

protected function registerResources(): void
{
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'cashier');
$this->loadTranslationsFrom(__DIR__ . '/../lang', 'cashier');
$this->loadViewsFrom(__DIR__.'/../resources/views', 'cashier');
$this->loadTranslationsFrom(__DIR__.'/../lang', 'cashier');
}

protected function publishMigrations(string $tag)
{
if (Cashier::$runsMigrations) {
$prefix = 'migrations/' . date('Y_m_d_His', time());
$prefix = 'migrations/'.date('Y_m_d_His', time());

$this->publishes([
__DIR__ . '/../database/migrations/create_applied_coupons_table.php.stub' => database_path($prefix . '_create_applied_coupons_table.php'),
__DIR__ . '/../database/migrations/create_redeemed_coupons_table.php.stub' => database_path($prefix . '_create_redeemed_coupons_table.php'),
__DIR__ . '/../database/migrations/create_credits_table.php.stub' => database_path($prefix . '_create_credits_table.php'),
__DIR__ . '/../database/migrations/create_orders_table.php.stub' => database_path($prefix . '_create_orders_table.php'),
__DIR__ . '/../database/migrations/create_order_items_table.php.stub' => database_path($prefix . '_create_order_items_table.php'),
__DIR__ . '/../database/migrations/create_subscriptions_table.php.stub' => database_path($prefix . '_create_subscriptions_table.php'),
__DIR__ . '/../database/migrations/create_payments_table.php.stub' => database_path($prefix . '_create_payments_table.php'),
__DIR__ . '/../database/migrations/create_refund_items_table.php.stub' => database_path($prefix . '_create_refund_items_table.php'),
__DIR__ . '/../database/migrations/create_refunds_table.php.stub' => database_path($prefix . '_create_refunds_table.php'),
__DIR__.'/../database/migrations/create_applied_coupons_table.php.stub' => database_path($prefix.'_create_applied_coupons_table.php'),
__DIR__.'/../database/migrations/create_redeemed_coupons_table.php.stub' => database_path($prefix.'_create_redeemed_coupons_table.php'),
__DIR__.'/../database/migrations/create_credits_table.php.stub' => database_path($prefix.'_create_credits_table.php'),
__DIR__.'/../database/migrations/create_orders_table.php.stub' => database_path($prefix.'_create_orders_table.php'),
__DIR__.'/../database/migrations/create_order_items_table.php.stub' => database_path($prefix.'_create_order_items_table.php'),
__DIR__.'/../database/migrations/create_subscriptions_table.php.stub' => database_path($prefix.'_create_subscriptions_table.php'),
__DIR__.'/../database/migrations/create_payments_table.php.stub' => database_path($prefix.'_create_payments_table.php'),
__DIR__.'/../database/migrations/create_refund_items_table.php.stub' => database_path($prefix.'_create_refund_items_table.php'),
__DIR__.'/../database/migrations/create_refunds_table.php.stub' => database_path($prefix.'_create_refunds_table.php'),
], $tag);
}
}

protected function publishUpdate(string $tag)
{
if (Cashier::$runsMigrations) {
$prefix = 'migrations/' . date('Y_m_d_His', time());
$prefix = 'migrations/'.date('Y_m_d_His', time());

$this->publishes([
__DIR__ . '/../database/migrations/upgrade_to_cashier_v3.php.stub' => database_path($prefix . '_upgrade_to_cashier_v3.php'),
__DIR__.'/../database/migrations/upgrade_to_cashier_v3.php.stub' => database_path($prefix.'_upgrade_to_cashier_v3.php'),
], $tag);
}
}

protected function publishConfig(string $tag)
{
$this->publishes([
__DIR__ . '/../config/cashier.php' => config_path('cashier.php'),
__DIR__ . '/../config/cashier_coupons.php' => config_path('cashier_coupons.php'),
__DIR__ . '/../config/cashier_plans.php' => config_path('cashier_plans.php'),
__DIR__.'/../config/cashier.php' => config_path('cashier.php'),
__DIR__.'/../config/cashier_coupons.php' => config_path('cashier_coupons.php'),
__DIR__.'/../config/cashier_plans.php' => config_path('cashier_plans.php'),
], $tag);
}

protected function publishTranslations(string $tag)
{
$this->publishes([
__DIR__ . '/../lang' => $this->app->langPath('vendor/cashier'),
__DIR__.'/../lang' => $this->app->langPath('vendor/cashier'),
], $tag);
}

protected function publishViews(string $tag)
{
$this->publishes([
__DIR__ . '/../resources/views' => $this->app->basePath('resources/views/vendor/cashier'),
__DIR__.'/../resources/views' => $this->app->basePath('resources/views/vendor/cashier'),
], $tag);
}

protected function mergeConfig(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/cashier.php', 'cashier');
$this->mergeConfigFrom(__DIR__ . '/../config/cashier_coupons.php', 'cashier_coupons');
$this->mergeConfigFrom(__DIR__ . '/../config/cashier_plans.php', 'cashier_plans');
$this->mergeConfigFrom(__DIR__.'/../config/cashier.php', 'cashier');
$this->mergeConfigFrom(__DIR__.'/../config/cashier_coupons.php', 'cashier_coupons');
$this->mergeConfigFrom(__DIR__.'/../config/cashier_plans.php', 'cashier_plans');
}

protected function configureCurrency()
Expand Down
2 changes: 0 additions & 2 deletions src/Charge/MandatedChargeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public function processAt(Carbon $pointInTime): self
}

/**
* @return ?Order
*
* @throws \Laravel\Cashier\Exceptions\InvalidMandateException
*/
public function create(): ?Order
Expand Down
2 changes: 1 addition & 1 deletion src/Console/Commands/CashierInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function handle()
{
if (app()->environment('production')) {
$this->alert('Running in production mode.');
if (!$this->confirm('Proceed installing Cashier?')) {
if (! $this->confirm('Proceed installing Cashier?')) {
return;
}
}
Expand Down
Loading

0 comments on commit 0ef360b

Please sign in to comment.