CanBuild   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 11
c 2
b 0
f 1
dl 0
loc 22
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 8 3
A guardIsBuild() 0 7 2
1
<?php
2
3
namespace Nip\Mail\MessageBuilder;
4
5
trait CanBuild
6
{
7
    protected $isBuild = false;
8
    protected $buildMethods = ['buildFrom', 'buildRecipients', 'buildSubject', 'buildBody', 'buildAttachments'];
9
10
    protected function guardIsBuild()
11
    {
12
        if ($this->isBuild) {
13
            return;
14
        }
15
        $this->build();
16
        $this->isBuild = true;
17
    }
18
19
    protected function build()
20
    {
21
        foreach ($this->buildMethods as $method) {
22
            if (method_exists($this, $method)) {
23
                $this->{$method}();
24
            }
25
        }
26
        $this->runCallbacks();
0 ignored issues
show
Bug introduced by
It seems like runCallbacks() 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

26
        $this->/** @scrutinizer ignore-call */ 
27
               runCallbacks();
Loading history...
27
    }
28
}
29