TranslationManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 56
rs 10
c 0
b 0
f 0
ccs 15
cts 15
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createTranslation() 0 8 1
A findAllTranslations() 0 4 1
A findTranslationsByLocaleAndDomain() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the AsmTranslationLoaderBundle package.
5
 *
6
 * (c) Marc Aschmann <[email protected]>
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
namespace Asm\TranslationLoaderBundle\Model;
13
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15
16
/**
17
 * Base {@link TranslationManagerInterface} implementation (can be extended by
18
 * concrete implementations).
19
 *
20
 * @author Christian Flothmann <[email protected]>
21
 */
22
abstract class TranslationManager implements TranslationManagerInterface
23
{
24
    /**
25
     * Class implementing the {@link TranslationInterface} managed by this manager
26
     *
27
     * @var string
28
     */
29
    protected $class;
30
31
    /**
32
     * @var EventDispatcherInterface
33
     */
34
    protected $eventDispatcher;
35
36
    /**
37
     * @param string $class Class name of managed {@link TranslationInterface} objects
38
     * @param EventDispatcherInterface $eventDispatcher Event dispatcher used to propagate new, modified
39
     *                                                  and removed translations
40
     */
41 10
    public function __construct($class, EventDispatcherInterface $eventDispatcher)
42
    {
43 10
        $this->class           = $class;
44 10
        $this->eventDispatcher = $eventDispatcher;
45 10
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50 1
    public function createTranslation()
51
    {
52
        /** @var TranslationInterface $translation */
53 1
        $translation = new $this->class();
54 1
        $translation->setDateCreated(new \DateTime());
55
56 1
        return $translation;
57
    }
58
59
    /**
60
     * {@inheritdoc}
61
     */
62 1
    public function findAllTranslations()
63
    {
64 1
        return $this->findTranslationsBy(array());
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 1
    public function findTranslationsByLocaleAndDomain($locale, $domain = 'messages')
71
    {
72 1
        return $this->findTranslationsBy(array(
73 1
            'transLocale'   => $locale,
74 1
            'messageDomain' => $domain,
75 1
        ));
76
    }
77
}
78