ReplyMessageFormFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 31
rs 10
c 1
b 1
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A createNewFormModel() 0 4 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\FormFactory;
12
13
use Miliooo\Messaging\Model\ThreadInterface;
14
use Miliooo\Messaging\User\ParticipantInterface;
15
use Miliooo\Messaging\Form\FormModel\ReplyMessageInterface;
16
use Symfony\Component\Form\FormInterface;
17
18
/**
19
 * The form factory for reply messages.
20
 *
21
 * @author Michiel Boeckaert <[email protected]>
22
 */
23
class ReplyMessageFormFactory extends AbstractMessageFormFactory
24
{
25
    /**
26
     * Creates a reply form from a form type with a form model set.
27
     *
28
     * It also sets some values on that form model.
29
     *
30
     * @param ThreadInterface      $thread The thread we answer to
31
     * @param ParticipantInterface $sender The sender of the reply
32
     *
33
     * @return FormInterface
34
     */
35
    public function create(ThreadInterface $thread, ParticipantInterface $sender)
36
    {
37
        $formModel = $this->createNewFormModel();
38
        $formModel->setThread($thread);
39
        $formModel->setSender($sender);
40
41
        return $this->formFactory->createNamed($this->formName, $this->formType, $formModel);
42
    }
43
44
    /**
45
     * Creates a new form model object from the modelClassName
46
     *
47
     * @return ReplyMessageInterface
48
     */
49
    protected function createNewFormModel()
50
    {
51
        return new $this->modelClassName;
52
    }
53
}
54