Passed
Push — main ( fb71e4...7f9a44 )
by Michael
01:00 queued 12s
created

AutoBinderClearCommand   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 9
c 2
b 0
f 1
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 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
        $clue = (new AutoBinder(
29 1
            $this->argument('folder')
30 1
        ))->cacheClue();
31
32 1
        collect($cache->get($clue))->each(
33 1
            fn ($concrete, $interface) => app()->offsetUnset($interface)
34
        );
35
36 1
        $cache->forget($clue);
37
    }
38
}
39