From 6c278ca2aaa66e6c7f7ff1dc7a652387b6c77999 Mon Sep 17 00:00:00 2001 From: adiologydev Date: Thu, 21 Nov 2024 18:36:08 +0000 Subject: [PATCH 1/2] Fix styling --- src/Traits/HasCredits.php | 28 +--------------------------- tests/HasCreditsTest.php | 2 +- tests/TestCase.php | 7 +++---- 3 files changed, 5 insertions(+), 32 deletions(-) diff --git a/src/Traits/HasCredits.php b/src/Traits/HasCredits.php index 7334a71..39d872d 100644 --- a/src/Traits/HasCredits.php +++ b/src/Traits/HasCredits.php @@ -17,11 +17,6 @@ public function creditTransactions(): MorphMany /** * Add credits to the model. - * - * @param float $amount - * @param string|null $description - * @param array $metadata - * @return Credit */ public function addCredits(float $amount, ?string $description = null, array $metadata = []): Credit { @@ -39,11 +34,6 @@ public function addCredits(float $amount, ?string $description = null, array $me /** * Deduct credits from the model. - * - * @param float $amount - * @param string|null $description - * @param array $metadata - * @return Credit */ public function deductCredits(float $amount, ?string $description = null, array $metadata = []): Credit { @@ -65,8 +55,6 @@ public function deductCredits(float $amount, ?string $description = null, array /** * Get the current balance of the model. - * - * @return float */ public function getCurrentBalance(): float { @@ -77,12 +65,6 @@ public function getCurrentBalance(): float /** * Transfer credits from the model to another model. - * - * @param self $recipient - * @param float $amount - * @param string|null $description - * @param array $metadata - * @return array */ public function transferCredits(self $recipient, float $amount, ?string $description = null, array $metadata = []): array { @@ -99,10 +81,6 @@ public function transferCredits(self $recipient, float $amount, ?string $descrip /** * Get the transaction history of the model. - * - * @param int $limit - * @param string $order - * @return Collection */ public function getTransactionHistory(int $limit = 10, string $order = 'desc'): Collection { @@ -114,9 +92,6 @@ public function getTransactionHistory(int $limit = 10, string $order = 'desc'): /** * Check if the model has enough credits. - * - * @param float $amount - * @return bool */ public function hasEnoughCredits(float $amount): bool { @@ -126,8 +101,7 @@ public function hasEnoughCredits(float $amount): bool /** * Get the balance of the model as of a specific date and time or timestamp. * - * @param \DateTimeInterface|int $dateTime - * @return float + * @param \DateTimeInterface|int $dateTime */ public function getBalanceAsOf($dateTime): float { diff --git a/tests/HasCreditsTest.php b/tests/HasCreditsTest.php index d1c6e02..cc88d1a 100644 --- a/tests/HasCreditsTest.php +++ b/tests/HasCreditsTest.php @@ -34,7 +34,7 @@ $this->user->addCredits(100.00); - expect(fn() => $this->user->deductCredits(150.00)) + expect(fn () => $this->user->deductCredits(150.00)) ->toThrow(InsufficientCreditsException::class); }); diff --git a/tests/TestCase.php b/tests/TestCase.php index e23c24f..ced063b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -3,7 +3,6 @@ namespace Climactic\Credits\Tests; use Climactic\Credits\CreditsServiceProvider; -use Illuminate\Database\Eloquent\Factories\Factory; use Orchestra\Testbench\TestCase as Orchestra; class TestCase extends Orchestra @@ -38,10 +37,10 @@ public function getEnvironmentSetUp($app) protected function defineDatabaseMigrations() { // Include the package migrations - include_once __DIR__ . '/../database/migrations/create_credits_table.php.stub'; - (include __DIR__ . '/../database/migrations/create_credits_table.php.stub')->up(); + include_once __DIR__.'/../database/migrations/create_credits_table.php.stub'; + (include __DIR__.'/../database/migrations/create_credits_table.php.stub')->up(); // Include the test migrations - $this->loadMigrationsFrom(__DIR__ . '/database/migrations'); + $this->loadMigrationsFrom(__DIR__.'/database/migrations'); } } From f6230cb4011d44af41129d8205a7a940bbabad27 Mon Sep 17 00:00:00 2001 From: adiologydev Date: Thu, 21 Nov 2024 18:46:48 +0000 Subject: [PATCH 2/2] Update CHANGELOG --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fba0af6..92a1601 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to `laravel-credits` will be documented in this file. +## v1.0.1 - 2024-11-21 + +- feat: `getBalanceAsOf` function now supports integer timestamps +- chore: remove unused config options (description length & required, decimal precision) +- chore: remove config values from migrations as they shouldn't be dynamic. +- chore: add typedocs for `HasCredits` trait. + ## v1.0.0 - 2024-11-20 Initial Release with Core Functionality