Skip to content

Commit

Permalink
improve type in driver and trait
Browse files Browse the repository at this point in the history
  • Loading branch information
EriBloo committed Oct 16, 2024
1 parent 15cc97e commit 2feafcd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/Concerns/CacheObjectActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public function delete(): bool
->delete($this);
}

/**
* @return Driver<TValue>
*/
protected function resolveDriver(): Driver
{
return app()->make('cache-driver');
Expand Down
9 changes: 3 additions & 6 deletions src/Contracts/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,24 @@

namespace EriBloo\CacheObjects\Contracts;

/**
* @template TValue
*/
interface Driver
{
/**
* @template TValue
*
* @param TValue $value
* @param CacheObject<TValue> $cacheObject
*/
public function set(mixed $value, CacheObject $cacheObject): string;

/**
* @template TValue
*
* @param CacheObject<TValue> $cacheObject
* @return TValue|null
*/
public function get(CacheObject $cacheObject): mixed;

/**
* @template TValue
*
* @param CacheObject<TValue> $cacheObject
*/
public function delete(CacheObject $cacheObject): bool;
Expand Down
5 changes: 5 additions & 0 deletions src/Drivers/CacheDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
use EriBloo\CacheObjects\Events\CacheObjectStored;
use Illuminate\Contracts\Cache\Store;

/**
* @template TValue
*
* @implements Driver<TValue>
*/
final class CacheDriver implements Driver
{
public function __construct(
Expand Down

0 comments on commit 2feafcd

Please sign in to comment.