Passed
Push — main ( 27f19e...cbb4d9 )
by Andrey
14:59 queued 12:22
created

Plugins::plugins()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 16
ccs 10
cts 10
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Concerns;
4
5
use Helldar\LaravelLangPublisher\Contracts\Plugin;
6
use Helldar\LaravelLangPublisher\Facades\Config;
7
8
trait Plugins
9
{
10
    protected $plugins;
11
12
    /**
13
     * @return array|\Helldar\LaravelLangPublisher\Plugins\Plugin[]
14
     */
15 16
    protected function plugins(): array
16
    {
17 16
        if (! empty($this->plugins)) {
18 16
            return $this->plugins;
19
        }
20
21 16
        $plugins = array_map(static function ($plugin) {
22
            /* @var \Helldar\LaravelLangPublisher\Plugins\Plugin $plugin */
23 16
            return $plugin::make();
24 16
        }, $this->getPlugins());
25
26 16
        $plugins = array_filter($plugins, static function (Plugin $plugin) {
27 16
            return $plugin->has();
28 16
        });
29
30 16
        return $this->plugins = $plugins;
31
    }
32
33 16
    protected function getPlugins(): array
34
    {
35 16
        $this->log('Getting a list of plugins...');
0 ignored issues
show
Bug introduced by
It seems like log() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        $this->/** @scrutinizer ignore-call */ 
36
               log('Getting a list of plugins...');
Loading history...
36
37 16
        return Config::plugins();
38
    }
39
}
40