CommentFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the Kreta package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Kreta\Component\Comment\Factory;
14
15
use Kreta\Component\Issue\Model\Interfaces\IssueInterface;
16
use Kreta\Component\User\Model\Interfaces\UserInterface;
17
18
/**
19
 * Class CommentFactory.
20
 *
21
 * @author Beñat Espiña <[email protected]>
22
 * @author Gorka Laucirica <[email protected]>
23
 */
24
class CommentFactory
25
{
26
    /**
27
     * The class name.
28
     *
29
     * @var string
30
     */
31
    protected $className;
32
33
    /**
34
     * Constructor.
35
     *
36
     * @param string $className The class name
37
     */
38
    public function __construct($className)
39
    {
40
        $this->className = $className;
41
    }
42
43
    /**
44
     * Creates an instance of comment.
45
     *
46
     * @param \Kreta\Component\Issue\Model\Interfaces\IssueInterface $issue The issue
47
     * @param \Kreta\Component\User\Model\Interfaces\UserInterface   $user  The user
48
     *
49
     * @return \Kreta\Component\Comment\Model\Interfaces\CommentInterface
50
     */
51
    public function create(IssueInterface $issue, UserInterface $user)
52
    {
53
        $comment = new $this->className();
54
55
        return $comment
56
            ->setIssue($issue)
57
            ->setWrittenBy($user);
58
    }
59
}
60