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

ContainerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A create() 0 8 1
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