Skip to content

Commit 8ecced2

Browse files
committed
Refactory to rely directly on the repository
1 parent 9aad556 commit 8ecced2

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

src/Drivers/Cache.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Cache implements StorageInterface
1313
*
1414
* @var \Illuminate\Cache\Repository;
1515
*/
16-
protected $store;
16+
protected $repository;
1717

1818
/**
1919
* The prefix for the cache key.
@@ -23,17 +23,17 @@ class Cache implements StorageInterface
2323
protected $prefix;
2424

2525
/**
26-
* Configures our cache driver with an instance of the cache store and a key
27-
* prefix.
26+
* Configures our cache driver with an instance of the cache repository and
27+
* a key prefix.
2828
*
29-
* @param \Illuminate\Contracts\Cache\Store $store
30-
* An instance of the cache store.
29+
* @param \Illuminate\Cache\Repository $repository
30+
* An instance of the cache repository.
3131
* @param string $prefix
3232
* A prefix for the cache keys.
3333
*/
34-
public function __construct(Store $store, string $prefix = 'rollout')
34+
public function __construct(Repository $repository, string $prefix = 'rollout')
3535
{
36-
$this->store = new Repository($store);
36+
$this->repository = $repository;
3737
$this->prefix = $prefix;
3838
}
3939

@@ -64,7 +64,7 @@ private function prefixKey($key) : string
6464
*/
6565
public function get($key)
6666
{
67-
return $this->store->get($this->prefixKey($key), null);
67+
return $this->repository->get($this->prefixKey($key), null);
6868
}
6969

7070
/**
@@ -80,7 +80,7 @@ public function get($key)
8080
*/
8181
public function set($key, $value)
8282
{
83-
$this->store->forever($this->prefixKey($key), $value);
83+
$this->repository->forever($this->prefixKey($key), $value);
8484
}
8585

8686
/**
@@ -94,6 +94,6 @@ public function set($key, $value)
9494
*/
9595
public function remove($key)
9696
{
97-
$this->store->forget($this->prefixKey($key));
97+
$this->repository->forget($this->prefixKey($key));
9898
}
9999
}

src/ServiceProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
class ServiceProvider extends IlluminateServiceProvider
99
{
1010
/**
11-
* Register the service provider.
11+
* Boot the service provider.
1212
*
1313
* @return void
1414
*/
15-
public function register()
15+
public function boot()
1616
{
1717
}
1818
}

tests/Drivers/CacheTest.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@
55
use Mockery;
66
use Tests\TestCase;
77
use Illuminate\Cache\ArrayStore;
8+
use Illuminate\Cache\Repository;
89
use Jaspaul\LaravelRollout\Drivers\Cache;
910

1011
class CacheTest extends TestCase
1112
{
1213
private $prefix = 'testing';
1314

14-
private $store;
15+
private $repository;
1516
private $cache;
1617

1718
/**
1819
* @before
1920
*/
2021
function setup_cache()
2122
{
22-
$this->store = new ArrayStore();
23-
$this->cache = new Cache($this->store, $this->prefix);
23+
$this->repository = new Repository(new ArrayStore());
24+
$this->cache = new Cache($this->repository, $this->prefix);
2425
}
2526

2627
/**

0 commit comments

Comments
 (0)