ContentFromTemplateMethods   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 30
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplateEngine() 0 8 2
A setTemplateEngine() 0 5 1
1
<?php
2
3
/**
4
 * This file is part of slick/mail package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Mail;
11
12
use Slick\Template\Template;
13
use Slick\Template\TemplateEngineInterface;
14
15
/**
16
 * Content From Template Methods
17
 *
18
 * @package Slick\Mail
19
 * @author  Filipe Silva <[email protected]>
20
 */
21
trait ContentFromTemplateMethods
22
{
23
24
    /**
25
     * Gets the Template Engine
26
     *
27
     * @return TemplateEngineInterface
28
     */
29 20
    public function getTemplateEngine()
30
    {
31 20
        if (null == $this->templateEngine) {
0 ignored issues
show
Bug introduced by
The property templateEngine does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
32 20
            $engine = (new Template())->initialize();
33 20
            $this->setTemplateEngine($engine);
34 10
        }
35 20
        return $this->templateEngine;
36
    }
37
38
    /**
39
     * Sets the Template Engine
40
     *
41
     * @param TemplateEngineInterface $templateEngine
42
     *
43
     * @return MessageBody|$this|self
44
     */
45 20
    public function setTemplateEngine(TemplateEngineInterface $templateEngine)
46
    {
47 20
        $this->templateEngine = $templateEngine;
48 20
        return $this;
49
    }
50
}