Completed
Push — master ( 8bcfe4...482f77 )
by Kamil
34:39 queued 21:52
created

CustomBookFactory::createCustom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace AppBundle\Factory;
15
16
use AppBundle\Entity\Book;
17
use Sylius\Component\Resource\Translation\Provider\TranslationLocaleProviderInterface;
18
19
final class CustomBookFactory
20
{
21
    /** @var string */
22
    private $className;
23
24
    /** @var TranslationLocaleProviderInterface */
25
    private $localeProvider;
26
27
    public function __construct(string $className, TranslationLocaleProviderInterface $localeProvider)
28
    {
29
        $this->className = $className;
30
        $this->localeProvider = $localeProvider;
31
    }
32
33
    public function createCustom(): Book
34
    {
35
        /** @var Book $book */
36
        $book = new $this->className;
37
38
        $book->setCurrentLocale($this->localeProvider->getDefaultLocaleCode());
39
        $book->setFallbackLocale($this->localeProvider->getDefaultLocaleCode());
40
41
        return $book;
42
    }
43
}
44