NewReplyDefaultProcessor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A process() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the MilioooMessageBundle package.
5
 *
6
 * (c) Michiel boeckaert <[email protected]>
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Miliooo\Messaging\Form\FormModelProcessor;
12
13
use Miliooo\Messaging\Builder\Message\ReplyBuilderInterface;
14
use Miliooo\Messaging\Form\FormModel\ReplyMessageInterface;
15
use Miliooo\Messaging\Manager\NewMessageManagerInterface;
16
use Miliooo\Messaging\Builder\Model\ReplyBuilderModel;
17
18
/**
19
 * Description of NewReplyDefaultProcessor
20
 *
21
 * @author Michiel Boeckaert <[email protected]>
22
 */
23
class NewReplyDefaultProcessor implements NewReplyFormProcessorInterface
24
{
25
    /**
26
     * A reply builder instance
27
     * @var ReplyBuilderInterface
28
     */
29
    protected $replyBuilder;
30
31
    /**
32
     * A new message manager instance
33
     *
34
     * @var NewMessageManagerInterface
35
     */
36
    protected $newMessageManager;
37
38
    /**
39
     * Constructor.
40
     *
41
     * @param ReplyBuilderInterface $replyBuilder
42
     * @param NewMessageManagerInterface $newMessageManager
43
     */
44
    public function __construct(ReplyBuilderInterface $replyBuilder, NewMessageManagerInterface $newMessageManager)
45
    {
46
        $this->replyBuilder = $replyBuilder;
47
        $this->newMessageManager = $newMessageManager;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function process(ReplyMessageInterface $formModel)
54
    {
55
        $replyBuilderModel = new ReplyBuilderModel($formModel);
56
        $thread = $this->replyBuilder->build($replyBuilderModel);
57
        $message = $thread->getLastMessage();
58
        $this->newMessageManager->saveNewReply($message);
59
    }
60
}
61