Composable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A compose() 0 20 2
1
<?php
2
3
namespace Helick\Blocks\Traits;
4
5
use Carbon_Fields\Block as CarbonFieldsBlock;
6
use Helick\Blocks\Exceptions\BlockException;
7
8
trait Composable
9
{
10
    /**
11
     * Compose the block.
12
     *
13
     * @return void
14
     */
15
    public function compose(): void
16
    {
17
        if (empty($this->name)) {
18
            throw BlockException::forEmptyName();
19
        }
20
21
        CarbonFieldsBlock::make($this->name)
22
                         ->add_fields($this->fields())
0 ignored issues
show
Bug introduced by
It seems like fields() 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

22
                         ->add_fields($this->/** @scrutinizer ignore-call */ fields())
Loading history...
23
                         ->set_description($this->description)
24
                         ->set_icon($this->icon)
25
                         ->set_category($this->category)
26
                         ->set_keywords($this->keywords)
27
                         ->set_preview_mode($this->preview)
28
                         ->set_parent($this->parent)
29
                         ->set_inner_blocks($this->nested)
30
                         ->set_inner_blocks_position($this->nestedPosition)
31
                         ->set_inner_blocks_template($this->nestedTemplates)
32
                         ->set_inner_blocks_template_lock($this->nestedLock)
33
                         ->set_allowed_inner_blocks($this->nestedBlocks)
34
                         ->set_render_callback([$this, 'render']);
35
    }
36
}
37