OrganizationFactory::createWithCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 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
15
namespace SWP\Component\MultiTenancy\Factory;
16
17
use SWP\Component\Common\Generator\GeneratorInterface;
18
use SWP\Component\MultiTenancy\Model\OrganizationInterface;
19
use SWP\Component\Storage\Factory\FactoryInterface;
20
21
class OrganizationFactory implements OrganizationFactoryInterface
22
{
23
    /**
24
     * @var GeneratorInterface
25
     */
26
    protected $generator;
27
28
    /**
29
     * @var FactoryInterface
30
     */
31
    protected $factory;
32
33
    /**
34
     * OrganizationFactory constructor.
35
     *
36
     * @param FactoryInterface   $factory
37
     * @param GeneratorInterface $generator
38
     */
39
    public function __construct(FactoryInterface $factory, GeneratorInterface $generator)
40
    {
41
        $this->factory = $factory;
42
        $this->generator = $generator;
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function create()
49
    {
50
        return $this->factory->create();
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function createWithCode()
57
    {
58
        /** @var OrganizationInterface $organization */
59
        $organization = $this->create();
60
        $organization->setCode($this->generator->generate(6));
61
62
        return $organization;
63
    }
64
}
65