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

Plugins   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 30
ccs 13
cts 13
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getPlugins() 0 5 1
A plugins() 0 16 2
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