Completed
Push — master ( 4d50ae...84674b )
by Tobias
06:42
created

CatalogueMessage::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
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
/**
17
 * A message representation for CatalogueManager.
18
 *
19
 * @author Tobias Nyholm <[email protected]>
20
 */
21
class CatalogueMessage
22
{
23
    /**
24
     * @var CatalogueManager
25
     */
26
    private $catalogueManager;
27
28
    /**
29
     * @var string
30
     */
31
    private $key;
32
33
    /**
34
     * @var string
35
     */
36
    private $message;
37
38
    /**
39
     * @var string
40
     */
41
    private $domain;
42
43
    /**
44
     * @var string
45
     */
46
    private $locale;
47
48
    /**
49
     * @param CatalogueManager $catalogueManager
50
     * @param string           $locale
51
     * @param string           $domain
52
     * @param string           $key
53
     * @param string           $message
54
     */
55
    public function __construct(CatalogueManager $catalogueManager, $locale, $domain, $key, $message)
56
    {
57
        $this->catalogueManager = $catalogueManager;
58
        $this->locale = $locale;
59
        $this->domain = $domain;
60
        $this->key = $key;
61
        $this->message = $message;
62
    }
63
64
    public function __toString()
65
    {
66
        return $this->getMessage();
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getKey()
73
    {
74
        return $this->key;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getDomain()
81
    {
82
        return $this->domain;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getLocale()
89
    {
90
        return $this->locale;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getMessage()
97
    {
98
        return $this->message;
99
    }
100
101
    public function getOtherTranslations()
102
    {
103
        $translations = $this->catalogueManager->getTranslations($this->domain, $this->getKey());
104
105
        unset($translations[$this->locale]);
106
107
        return $translations;
108
    }
109
110
    public function getSourceLocations()
111
    {
112
        return $this->catalogueManager->getSourceLocations($this->domain, $this->key);
113
    }
114
115
    public function isNew()
116
    {
117
        return $this->catalogueManager->isNew($this->domain, $this->key);
118
    }
119
120
    public function isObsolete()
121
    {
122
        return $this->catalogueManager->isObsolete($this->domain, $this->key);
123
    }
124
}
125