Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary class #11548

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions app/Libraries/Fulfillments/ApplySupporterTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace App\Libraries\Fulfillments;

use App\Models\Store\OrderItem;
use App\Models\User;
use App\Models\UserDonation;
use Carbon\Carbon;
Expand All @@ -13,7 +14,7 @@
/**
* Applies a Supporter Tag donation from a store transaction.
*/
class ApplySupporterTag extends OrderItemFulfillment
class ApplySupporterTag implements Fulfillable
{
public static function addDuration(Carbon $time, int $duration): Carbon
{
Expand All @@ -27,6 +28,10 @@ public static function addDuration(Carbon $time, int $duration): Carbon
private User $donor;
private User $target;

public function __construct(protected OrderItem $orderItem)
{
}

public function cancelledTransactionId()
{
return "{$this->getTransactionId()}-cancel";
Expand All @@ -35,7 +40,7 @@ public function cancelledTransactionId()
/**
* Performs the opration.
*
* @throws Illuminate\Database\Eloquent\ModelNotFoundException If the donor or target could not be found.
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException If the donor or target could not be found.
*/
public function run()
{
Expand All @@ -62,7 +67,7 @@ public function run()
/**
* Revokes the operation.
*
* @throws Illuminate\Database\Eloquent\ModelNotFoundException If the donor or target could not be found.
* @throws \Illuminate\Database\Eloquent\ModelNotFoundException If the donor or target could not be found.
*/
public function revoke()
{
Expand Down Expand Up @@ -119,6 +124,11 @@ private function applySubscription()
$this->target->osu_subscriber = true;
}

private function getTransactionId()
{
return "{$this->orderItem->order->transaction_id}-{$this->orderItem->id}";
}

private function revokeSubscription()
{
$previous = static::addDuration($this->target->osu_subscriptionexpiry, -$this->duration);
Expand All @@ -128,7 +138,7 @@ private function revokeSubscription()

private function setup()
{
/** @var ExtraDataSupporterTag $extraData */
/** @var \App\Models\Store\ExtraDataSupporterTag $extraData */
$extraData = $this->orderItem->extra_data;

$this->amount = $this->orderItem->cost;
Expand Down
21 changes: 0 additions & 21 deletions app/Libraries/Fulfillments/OrderItemFulfillment.php

This file was deleted.