Passed
Pull Request — main (#3)
by Michael
03:25
created

AutoBinderClearCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 8
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 1
b 0
f 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 1
1
<?php
2
3
namespace MichaelRubel\AutoBinder\Commands;
4
5
use Illuminate\Cache\Repository;
6
use Illuminate\Console\Command;
7
use MichaelRubel\AutoBinder\AutoBinder;
0 ignored issues
show
Bug introduced by
The type MichaelRubel\AutoBinder\AutoBinder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
class AutoBinderClearCommand extends Command
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $signature = 'binder:clear {folder : Folder to clear the cache from}';
15
16
    /**
17
     * @var string
18
     */
19
    protected $description = 'Clear a cached bindings';
20
21
    /**
22
     * @param  Repository  $cache
23
     *
24
     * @return void
25
     */
26 1
    public function handle(Repository $cache): void
27
    {
28 1
        $folder = $this->argument('folder');
29 1
        $clue   = (new AutoBinder($folder))->cacheClue();
30
31 1
        collect($cache->get($clue))->each(
32 1
            fn ($concrete, $interface) => app()->offsetUnset($interface)
33
        );
34
35 1
        $cache->forget($clue);
36
    }
37
}