Test Failed
Push — master ( 9d4e41...1cd52c )
by Sebastian
03:24
created

Context::getMacros()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * citeproc-php
4
 *
5
 * @link        http://github.com/seboettg/citeproc-php for the source repository
6
 * @copyright   Copyright (c) 2016 Sebastian Böttger.
7
 * @license     https://opensource.org/licenses/MIT
8
 */
9
10
namespace Seboettg\CiteProc;
11
use Seboettg\CiteProc\Data\DataList;
12
use Seboettg\CiteProc\Locale\Locale;
13
use Seboettg\CiteProc\Style\Bibliography;
14
use Seboettg\CiteProc\Style\Citation;
15
use Seboettg\CiteProc\Style\Macro;
16
use Seboettg\CiteProc\Style\Sort\Sort;
17
use Seboettg\CiteProc\Style\Root;
18
use Seboettg\Collection\ArrayList;
19
20
21
/**
22
 * Class Context
23
 * @package Seboettg\CiteProc
24
 *
25
 * @author Sebastian Böttger <[email protected]>
26
 */
27
class Context
28
{
29
    /**
30
     * @var ArrayList
31
     */
32
    private $macros;
33
34
    /**
35
     * @var Locale
36
     */
37
    private $locale;
38
39
    /**
40
     * @var Bibliography
41
     */
42
    private $bibliography;
43
44
    /**
45
     * @var Citation
46
     */
47
    private $citation;
48
49
    /**
50
     * @var Sort
51
     */
52
    private $sorting;
53
54
    /**
55
     * @var string
56
     */
57
    private $mode;
58
59
    /**
60
     * @var DataList
61
     */
62
    private $citationItems;
63
64
    /**
65
     * @var ArrayList
66
     */
67
    private $results;
68
69
    /**
70
     * @var Root
71
     */
72
    private $root;
73
74
    /**
75
     * @var CiteProc
76
     */
77
    private $citeProc;
0 ignored issues
show
Unused Code introduced by
The property $citeProc is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
78
79
    public function __construct($locale = null)
80
    {
81
        if (!empty($locale)) {
82
            $this->locale = $locale;
83
        }
84
85
        $this->macros = new ArrayList();
86
        $this->citationItems = new DataList();
87
        $this->results = new ArrayList();
88
    }
89
90
    public function addMacro($key, $macro)
91
    {
92
        $this->macros->add($key, $macro);
93
    }
94
95
    /**
96
     * @param $key
97
     * @return Macro
98
     */
99
    public function getMacro($key)
100
    {
101
        return $this->macros->get($key);
102
    }
103
104
    /**
105
     * @param Locale $locale
106
     */
107
    public function setLocale(Locale $locale)
108
    {
109
        $this->locale = $locale;
110
    }
111
112
    /**
113
     * @return Locale
114
     */
115
    public function getLocale()
116
    {
117
        return $this->locale;
118
    }
119
120
    /**
121
     * @return Bibliography
122
     */
123
    public function getBibliography()
124
    {
125
        return $this->bibliography;
126
    }
127
128
    /**
129
     * @param Bibliography $bibliography
130
     */
131
    public function setBibliography(Bibliography $bibliography)
132
    {
133
        $this->bibliography = $bibliography;
134
    }
135
136
    /**
137
     * @return Citation
138
     */
139
    public function getCitation()
140
    {
141
        return $this->citation;
142
    }
143
144
    /**
145
     * @param Citation $citation
146
     */
147
    public function setCitation($citation)
148
    {
149
        $this->citation = $citation;
150
    }
151
152
    public function setSorting($sorting)
153
    {
154
        $this->sorting = $sorting;
155
    }
156
157
    public function getSorting()
158
    {
159
        return $this->sorting;
160
    }
161
162
    /**
163
     * return the render mode (citation|bibliography)
164
     * @return string
165
     */
166
    public function getMode()
167
    {
168
        return $this->mode;
169
    }
170
171
    /**
172
     * @param string $mode
173
     */
174
    public function setMode($mode)
175
    {
176
        $this->mode = $mode;
177
    }
178
179
    /**
180
     * returns true if the render mode is set to citation
181
     * @return bool
182
     */
183
    public function isModeCitation()
184
    {
185
        return $this->mode === "citation";
186
    }
187
188
    /**
189
     * returns true if the render mode is set to bibliography
190
     * @return bool
191
     */
192
    public function isModeBibliography()
193
    {
194
        return $this->mode === "bibliography";
195
    }
196
197
    /**
198
     * @return DataList
199
     */
200
    public function getCitationItems()
201
    {
202
        return $this->citationItems;
203
    }
204
205
    /**
206
     * @param DataList $citationItems
207
     */
208
    public function setCitationItems(&$citationItems)
209
    {
210
        $this->citationItems = $citationItems;
211
    }
212
213
    public function hasCitationItems()
214
    {
215
        return ($this->citationItems->count() > 0);
216
    }
217
218
    /**
219
     * @return ArrayList
220
     */
221
    public function getMacros()
222
    {
223
        return $this->macros;
224
    }
225
226
    /**
227
     * @return ArrayList
228
     */
229
    public function getResults()
230
    {
231
        return $this->results;
232
    }
233
234
    /**
235
     * @return Root
236
     */
237
    public function getRoot()
238
    {
239
        return $this->root;
240
    }
241
242
    /**
243
     * @param Root $root
244
     */
245
    public function setRoot($root)
246
    {
247
        $this->root = $root;
248
    }
249
250
}