Passed
Push — master ( 6f5910...53ef6f )
by Josh
09:09 queued 11s
created

PluginTrait::_setPluginComponents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
/**
3
 * Spoon plugin for Craft CMS 3.x
4
 *
5
 * Enhance Matrix
6
 *
7
 * @link      https://angell.io
8
 * @copyright Copyright (c) 2018 Angell & Co
9
 */
10
11
namespace angellco\spoon\base;
12
13
use angellco\spoon\services\BlockTypes;
14
use angellco\spoon\services\Fields;
15
use angellco\spoon\services\Loader;
16
use angellco\spoon\Spoon;
17
18
/**
19
 * Trait PluginTrait
20
 *
21
 * @property-read BlockTypes $blockTypes The block types service
22
 * @property-read Fields $fields The fields service
23
 * @property-read Loader $loader The loader service
24
 * @package angellco\spoon\base
25
 */
26
trait PluginTrait
27
{
28
    // Static Properties
29
    // =========================================================================
30
31
    /**
32
     * @var Spoon
33
     */
34
    public static $plugin;
35
36
    // Public Methods
37
    // =========================================================================
38
39
    /**
40
     * @return BlockTypes
41
     */
42
    public function getBlockTypes(): BlockTypes
43
    {
44
        return $this->get('blockTypes');
0 ignored issues
show
Bug introduced by
It seems like get() 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

44
        return $this->/** @scrutinizer ignore-call */ get('blockTypes');
Loading history...
45
    }
46
47
    /**
48
     * @return Loader
49
     */
50
    public function getLoader(): Loader
51
    {
52
        return $this->get('loader');
53
    }
54
55
    /**
56
     * @return Fields
57
     */
58
    public function getFields(): Fields
59
    {
60
        return $this->get('fields');
61
    }
62
63
    // Private Methods
64
    // =========================================================================
65
66
    private function _setPluginComponents()
67
    {
68
        $this->setComponents([
0 ignored issues
show
Bug introduced by
It seems like setComponents() 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

68
        $this->/** @scrutinizer ignore-call */ 
69
               setComponents([
Loading history...
69
            'blockTypes' => BlockTypes::class,
70
            'loader' => Loader::class,
71
            'fields' => Fields::class,
72
        ]);
73
    }
74
}