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 diff --git a/src/Traits/HasCredits.php b/src/Traits/HasCredits.php index 1a91e08..2e28797 100644 --- a/src/Traits/HasCredits.php +++ b/src/Traits/HasCredits.php @@ -20,11 +20,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 { @@ -52,11 +47,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 { @@ -88,8 +78,6 @@ public function deductCredits(float $amount, ?string $description = null, array /** * Get the current balance of the model. - * - * @return float */ public function getCurrentBalance(): float { @@ -100,12 +88,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 { @@ -139,10 +121,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 { @@ -154,9 +132,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 { @@ -166,8 +141,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'); } }