Completed
Push — master ( db7fdf...6d7a34 )
by Rafał
08:10
created

OrganizationFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Component.
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 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Component\MultiTenancy\Factory;
15
16
use SWP\Component\Common\Generator\GeneratorInterface;
17
use SWP\Component\MultiTenancy\Model\OrganizationInterface;
18
use SWP\Component\Storage\Factory\FactoryInterface;
19
20
class OrganizationFactory implements OrganizationFactoryInterface
21
{
22
    /**
23
     * @var GeneratorInterface
24
     */
25
    protected $generator;
26
27
    /**
28
     * @var FactoryInterface
29
     */
30
    protected $factory;
31
32
    /**
33
     * OrganizationFactory constructor.
34
     *
35
     * @param FactoryInterface   $factory
36
     * @param GeneratorInterface $generator
37
     */
38
    public function __construct(FactoryInterface $factory, GeneratorInterface $generator)
39
    {
40
        $this->factory = $factory;
41
        $this->generator = $generator;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function create()
48
    {
49
        return $this->factory->create();
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function createWithCode()
56
    {
57
        /** @var OrganizationInterface $organization */
58
        $organization = $this->create();
59
        $organization->setCode($this->generator->generate(6));
60
61
        return $organization;
62
    }
63
}
64