Completed
Push — master ( 3d485f...407dff )
by Paweł
66:49
created

ContainerFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Web Publisher Core Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\CoreBundle\Factory;
16
17
use SWP\Component\Common\Generator\RandomStringGenerator;
18
use SWP\Component\Revision\RevisionAwareInterface;
19
use SWP\Component\Storage\Factory\FactoryInterface;
20
21
class ContainerFactory implements FactoryInterface
22
{
23
    /**
24
     * @var RandomStringGenerator
25
     */
26
    protected $randomStringGenerator;
27
28
    /**
29
     * @var string
30
     */
31
    private $className;
32
33
    /**
34
     * Factory constructor.
35
     *
36
     * @param string $className
37
     */
38
    public function __construct($className, $randomStringGenerator)
39
    {
40
        $this->className = $className;
41
        $this->randomStringGenerator = $randomStringGenerator;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function create()
48
    {
49
        /** @var RevisionAwareInterface $container */
50
        $container = new $this->className();
51
        $container->setUuid($this->randomStringGenerator->generate(11));
52
53
        return $container;
54
    }
55
}
56