| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php namespace GeneaLabs\LaravelModelCaching\Console\Commands; |
||
| 33 | protected function flushModelCache(string $option) : int |
||
| 34 | { |
||
| 35 | $model = new $option; |
||
| 36 | $usesCachableTrait = $this->getAllTraitsUsedByClass($option) |
||
| 37 | ->contains("GeneaLabs\LaravelModelCaching\Traits\Cachable"); |
||
| 38 | |||
| 39 | if (! $usesCachableTrait) { |
||
| 40 | $this->error("'{$option}' is not an instance of CachedModel."); |
||
| 41 | $this->line("Only CachedModel instances can be flushed."); |
||
| 42 | |||
| 43 | return 1; |
||
| 44 | } |
||
| 45 | |||
| 46 | $model->flushCache(); |
||
| 47 | $this->info("✔︎ Cache for model '{$option}' has been flushed."); |
||
| 48 | |||
| 49 | return 0; |
||
| 50 | } |
||
| 72 |