Passed
Pull Request — main (#84)
by Andrey
49:37 queued 34:36
created

Containable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A container() 0 11 2
1
<?php
2
3
namespace Helldar\LaravelLangPublisher\Concerns;
4
5
use Illuminate\Container\Container;
6
7
/** @mixin \Helldar\LaravelLangPublisher\Concerns\Logger */
8
trait Containable
9
{
10
    protected static $containers = [];
11
12
    protected function container(string $class, array $parameters = [])
13
    {
14
        if (! isset(static::$containers[$class])) {
15
            $this->log('Creating container: ' . $class);
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

15
            $this->/** @scrutinizer ignore-call */ 
16
                   log('Creating container: ' . $class);
Loading history...
16
17
            static::$containers[$class] = Container::getInstance()->make($class, $parameters);
18
        }
19
20
        $this->log('Getting the container: ' . $class);
21
22
        return static::$containers[$class];
23
    }
24
}
25