Passed
Push — master ( a9f547...49cca7 )
by Raffael
04:18
created

NodeMessage   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
dl 0
loc 66
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getSubject() 0 7 1
A getBody() 0 7 1
A renderTemplate() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2018 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\App\Notification;
13
14
use Balloon\Filesystem\Node\NodeInterface;
15
use Balloon\Server\User;
16
17
class NodeMessage implements MessageInterface
18
{
19
    /**
20
     * Message type.
21
     *
22
     * @var string
23
     */
24
    protected $type;
25
26
    /**
27
     * Node.
28
     *
29
     * @var NodeInterface
30
     */
31
    protected $node;
32
33
    /**
34
     * Template handler.
35
     *
36
     * @var TemplateHandler
37
     */
38
    protected $template;
39
40
    /**
41
     * Constructor.
42
     */
43
    public function __construct(string $type, TemplateHandler $template, NodeInterface $node)
44
    {
45
        $this->type = $type;
46
        $this->template = $template;
47
        $this->node = $node;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function getSubject(User $user): string
54
    {
55
        return $this->template->getSubject($this->type, [
56
            'user' => $user,
57
            'node' => $this->node,
58
        ]);
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function getBody(User $user): string
65
    {
66
        return $this->template->getBody($this->type, [
67
            'user' => $user,
68
            'node' => $this->node,
69
        ]);
70
    }
71
72
    /**
73
     * {@inheritdoc}
74
     */
75
    public function renderTemplate(string $template, User $user): string
76
    {
77
        return $this->template->renderTemplate($this->type, $template, [
78
            'user' => $user,
79
            'node' => $this->node,
80
        ]);
81
    }
82
}
83