Completed
Push — 2.x ( dbb9af...517b3d )
by Hari
02:53
created

Package::getMessages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 *
4
 * This file is part of the Aura Project for PHP.
5
 *
6
 * @package Aura.Intl
7
 *
8
 * @license http://opensource.org/licenses/MIT MIT
9
 *
10
 */
11
namespace Aura\Intl;
12
13
/**
14
 *
15
 * Message Catalog
16
 *
17
 * @package Aura.Intl
18
 *
19
 */
20
class Package
21
{
22
    /**
23
     *
24
     * Message keys and translations in this package.
25
     *
26
     * @var array
27
     *
28
     */
29
    protected $messages;
30
31
    /**
32
     *
33
     * The name of a fallback package to use when a message key does not
34
     * exist.
35
     *
36
     * @var string
37
     *
38
     */
39
    protected $fallback;
40
41
    /**
42
     *
43
     * The name of the formatter to use when formatting translated messages.
44
     *
45
     * @var string
46
     *
47
     */
48
    protected $formatter;
49
50
    /**
51
     *
52
     * Constructor.
53
     *
54
     * @param string $formatter The name of the formatter to use.
55
     *
56
     * @param string $fallback The name of the fallback package to use.
57
     *
58
     * @param array $messages The messages in this package.
59
     *
60
     */
61 5
    public function __construct(
62
        $formatter      = 'basic',
63
        $fallback       = null,
64
        array $messages = []
65
    ) {
66 5
        $this->formatter = $formatter;
67 5
        $this->fallback  = $fallback;
68 5
        $this->messages  = $messages;
69 5
    }
70
71
    /**
72
     *
73
     * Sets the messages for this package.
74
     *
75
     * @param array $messages The messages for this package.
76
     *
77
     * @return void
78
     *
79
     */
80 3
    public function setMessages(array $messages)
81
    {
82 3
        $this->messages = $messages;
83 3
    }
84
85
    /**
86
     *
87
     * Gets the messages for this package.
88
     *
89
     * @return array
90
     *
91
     */
92 3
    public function getMessages()
93
    {
94 3
        return $this->messages;
95
    }
96
97
    /**
98
     *
99
     * Sets the formatter name for this package.
100
     *
101
     * @param string $formatter The formatter name for this package.
102
     *
103
     * @return void
104
     *
105
     */
106 1
    public function setFormatter($formatter)
107
    {
108 1
        $this->formatter = $formatter;
109 1
    }
110
111
    /**
112
     *
113
     * Gets the formatter name for this package.
114
     *
115
     * @return string
116
     *
117
     */
118 3
    public function getFormatter()
119
    {
120 3
        return $this->formatter;
121
    }
122
123
    /**
124
     *
125
     * Sets the fallback package name.
126
     *
127
     * @param string $fallback The fallback package name.
128
     *
129
     * @return void
130
     *
131
     */
132 1
    public function setFallback($fallback)
133
    {
134 1
        $this->fallback = $fallback;
135 1
    }
136
137
    /**
138
     *
139
     * Gets the fallback package name.
140
     *
141
     * @return string
142
     *
143
     */
144 3
    public function getFallback()
145
    {
146 3
        return $this->fallback;
147
    }
148
}
149