Skip to content

Commit e271997

Browse files
committed
FIx typehint compatibility & enforce consistency
1 parent 522037f commit e271997

File tree

3 files changed

+17
-39
lines changed

3 files changed

+17
-39
lines changed

src/Contracts/CacheableContract.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface CacheableContract
99
/**
1010
* Set the repository cache lifetime.
1111
*
12-
* @param float|int $cacheLifetime
12+
* @param int $cacheLifetime
1313
*
1414
* @return $this
1515
*/
@@ -18,9 +18,9 @@ public function setCacheLifetime($cacheLifetime);
1818
/**
1919
* Get the repository cache lifetime.
2020
*
21-
* @return float|int
21+
* @return int
2222
*/
23-
public function getCacheLifetime();
23+
public function getCacheLifetime(): int;
2424

2525
/**
2626
* Set the repository cache driver.

src/Repositories/EloquentRepository.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,31 +315,31 @@ public function restore($id)
315315
/**
316316
* {@inheritdoc}
317317
*/
318-
public function beginTransaction()
318+
public function beginTransaction(): void
319319
{
320320
$this->getContainer('db')->beginTransaction();
321321
}
322322

323323
/**
324324
* {@inheritdoc}
325325
*/
326-
public function commit()
326+
public function commit(): void
327327
{
328328
$this->getContainer('db')->commit();
329329
}
330330

331331
/**
332332
* {@inheritdoc}
333333
*/
334-
public function rollBack()
334+
public function rollBack(): void
335335
{
336336
$this->getContainer('db')->rollBack();
337337
}
338338

339339
/**
340340
* {@inheritdoc}
341341
*/
342-
public function count($columns = '*')
342+
public function count($columns = '*'): int
343343
{
344344
return $this->executeCallback(get_called_class(), __FUNCTION__, func_get_args(), function () use ($columns) {
345345
return $this->prepareQuery($this->createModel())->count($columns);

src/Traits/Cacheable.php

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ trait Cacheable
1111
/**
1212
* The repository cache lifetime.
1313
*
14-
* @var float|int
14+
* @var int
1515
*/
1616
protected $cacheLifetime;
1717

@@ -114,11 +114,7 @@ protected function flushCacheKeys(): array
114114
}
115115

116116
/**
117-
* Set the repository cache lifetime.
118-
*
119-
* @param float|int $cacheLifetime
120-
*
121-
* @return $this
117+
* {@inheritdoc}
122118
*/
123119
public function setCacheLifetime($cacheLifetime)
124120
{
@@ -128,24 +124,16 @@ public function setCacheLifetime($cacheLifetime)
128124
}
129125

130126
/**
131-
* Get the repository cache lifetime.
132-
*
133-
* @return float|int
127+
* {@inheritdoc}
134128
*/
135-
public function getCacheLifetime()
129+
public function getCacheLifetime(): int
136130
{
137-
$lifetime = $this->getContainer('config')->get('rinvex.repository.cache.lifetime');
138-
139131
// Return value even if it's zero "0" (which means cache is disabled)
140-
return ! is_null($this->cacheLifetime) ? $this->cacheLifetime : $lifetime;
132+
return $this->cacheLifetime ?? $this->getContainer('config')->get('rinvex.repository.cache.lifetime');
141133
}
142134

143135
/**
144-
* Set the repository cache driver.
145-
*
146-
* @param string $cacheDriver
147-
*
148-
* @return $this
136+
* {@inheritdoc}
149137
*/
150138
public function setCacheDriver($cacheDriver)
151139
{
@@ -155,21 +143,15 @@ public function setCacheDriver($cacheDriver)
155143
}
156144

157145
/**
158-
* Get the repository cache driver.
159-
*
160-
* @return string
146+
* {@inheritdoc}
161147
*/
162148
public function getCacheDriver(): string
163149
{
164150
return $this->cacheDriver;
165151
}
166152

167153
/**
168-
* Enable repository cache clear.
169-
*
170-
* @param bool $status
171-
*
172-
* @return $this
154+
* {@inheritdoc}
173155
*/
174156
public function enableCacheClear($status = true)
175157
{
@@ -179,19 +161,15 @@ public function enableCacheClear($status = true)
179161
}
180162

181163
/**
182-
* Determine if repository cache clear is enabled.
183-
*
184-
* @return bool
164+
* {@inheritdoc}
185165
*/
186166
public function isCacheClearEnabled(): bool
187167
{
188168
return $this->cacheClearEnabled;
189169
}
190170

191171
/**
192-
* Forget the repository cache.
193-
*
194-
* @return $this
172+
* {@inheritdoc}
195173
*/
196174
public function forgetCache()
197175
{

0 commit comments

Comments
 (0)