Completed
Push — 1.2 ( 92568a...918d86 )
by Kamil
24:00
created

CustomBookFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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