MessageBodyTemplate   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
eloc 4
dl 0
loc 54
c 2
b 1
f 0
ccs 6
cts 6
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTextLayout() 0 3 1
A getHtmlLayout() 0 3 1
A __construct() 0 5 1
A getViewPath() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Mailer;
6
7
use Yiisoft\View\ViewContextInterface;
8
9
/**
10
 * Stores the path to the view file directory and the layout view names.
11
 */
12
final class MessageBodyTemplate implements ViewContextInterface
13
{
14
    /**
15
     * @param string $viewPath The directory containing view files for composing mail messages.
16
     * @param string $htmlLayout The HTML layout view name. It is the layout used to render HTML mail body. If the value
17
     * is empty string, no layout will be applied.
18
     *
19
     * The property can take the following values:
20
     *
21
     * - a relative view name: a view file relative to {@see MessageBodyRenderer::$viewPath}, e.g., 'layouts/html'.
22
     * - an empty string: the layout is disabled.
23
     * @param string $textLayout The TEXT layout view name. This is the layout used to render TEXT mail body. If the
24
     * value is empty string, no layout will be applied.
25
     *
26
     * The property can take the following values:
27
     *
28
     * - a relative view name: a view file relative to {@see MessageBodyRenderer::$viewPath}, e.g., 'layouts/text'.
29
     * - an empty string: the layout is disabled.
30
     */
31
    public function __construct(
32
        private string $viewPath,
33
        private string $htmlLayout = 'layouts/html',
34
        private string $textLayout = 'layouts/text'
35
    ) {
36
    }
37
38
    /**
39
     * Returns the directory containing view files for composing mail messages.
40
     *
41
     * @return string The directory containing view files for composing mail messages.
42
     */
43
    public function getViewPath(): string
44
    {
45
        return $this->viewPath;
46
    }
47
48 48
    /**
49
     * Returns the HTML layout view name.
50
     *
51
     * @return string The HTML layout view name.
52
     */
53 48
    public function getHtmlLayout(): string
54 48
    {
55 48
        return $this->htmlLayout;
56
    }
57
58
    /**
59
     * Returns the TEXT layout view name.
60
     *
61
     * @return string The TEXT layout view name.
62
     */
63 12
    public function getTextLayout(): string
64
    {
65 12
        return $this->textLayout;
66
    }
67
}
68