Completed
Push — master ( 00951d...4d50ae )
by Tobias
09:16
created

Message::getOtherTranslations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[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 Translation\Bundle\Model;
13
14
use Translation\Bundle\Catalogue\CatalogueManager;
15
16
class Message
17
{
18
    /**
19
     * @var CatalogueManager
20
     */
21
    private $catalogueManager;
22
23
    /**
24
     * @var string
25
     */
26
    private $key;
27
28
    /**
29
     * @var string
30
     */
31
    private $message;
32
33
    /**
34
     * @var string
35
     */
36
    private $domain;
37
38
    /**
39
     * @var string
40
     */
41
    private $locale;
42
43
    /**
44
     * @param CatalogueManager $catalogueManager
45
     * @param string           $locale
46
     * @param string           $domain
47
     * @param string           $key
48
     * @param string           $message
49
     */
50
    public function __construct(CatalogueManager $catalogueManager, $locale, $domain, $key, $message)
51
    {
52
        $this->catalogueManager = $catalogueManager;
53
        $this->locale = $locale;
54
        $this->domain = $domain;
55
        $this->key = $key;
56
        $this->message = $message;
57
    }
58
59
    public function __toString()
60
    {
61
        return $this->getMessage();
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getKey()
68
    {
69
        return $this->key;
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    public function getDomain()
76
    {
77
        return $this->domain;
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getLocale()
84
    {
85
        return $this->locale;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    public function getMessage()
92
    {
93
        return $this->message;
94
    }
95
96
    public function getOtherTranslations()
97
    {
98
        $translations = $this->catalogueManager->getTranslations($this->domain, $this->getKey());
99
100
        unset($translations[$this->locale]);
101
102
        return $translations;
103
    }
104
105
    public function getSourceLocations()
106
    {
107
        return $this->catalogueManager->getSourceLocations($this->domain, $this->key);
108
    }
109
110
    public function isNew()
111
    {
112
        return $this->catalogueManager->isNew($this->domain, $this->key);
113
    }
114
115
    public function isObsolete()
116
    {
117
        return $this->catalogueManager->isObsolete($this->domain, $this->key);
118
    }
119
}
120