Passed
Push — master ( d2184e...ee1eb5 )
by Sebastian
04:46
created

Context::getMacro()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/*
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
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\Root\Info;
14
use Seboettg\CiteProc\Style\Bibliography;
15
use Seboettg\CiteProc\Style\Citation;
16
use Seboettg\CiteProc\Style\Macro;
17
use Seboettg\CiteProc\Style\Options\BibliographyOptions;
18
use Seboettg\CiteProc\Style\Options\CitationOptions;
19
use Seboettg\CiteProc\Style\Options\GlobalOptions;
20
use Seboettg\CiteProc\Style\Sort\Sort;
21
use Seboettg\CiteProc\Root\Root;
22
use Seboettg\CiteProc\Styles\Css\CssStyle;
23
use Seboettg\Collection\ArrayList;
24
25
26
/**
27
 * Class Context
28
 * @package Seboettg\CiteProc
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
29
 *
30
 * @author Sebastian Böttger <[email protected]>
31
 */
3 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
32
class Context
33
{
34
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
35
     * @var ArrayList
36
     */
37
    private $macros;
0 ignored issues
show
Coding Style introduced by
Private member variable "macros" must be prefixed with an underscore
Loading history...
38
39
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
40
     * @var Locale
41
     */
42
    private $locale;
0 ignored issues
show
Coding Style introduced by
Private member variable "locale" must be prefixed with an underscore
Loading history...
43
44
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
45
     * @var Bibliography
46
     */
47
    private $bibliography;
0 ignored issues
show
Coding Style introduced by
Private member variable "bibliography" must be prefixed with an underscore
Loading history...
48
49
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
50
     * @var Citation
51
     */
52
    private $citation;
0 ignored issues
show
Coding Style introduced by
Private member variable "citation" must be prefixed with an underscore
Loading history...
53
54
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
55
     * @var Sort
56
     */
57
    private $sorting;
0 ignored issues
show
Coding Style introduced by
Private member variable "sorting" must be prefixed with an underscore
Loading history...
58
59
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
60
     * @var string
61
     */
62
    private $mode;
0 ignored issues
show
Coding Style introduced by
Private member variable "mode" must be prefixed with an underscore
Loading history...
63
64
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
65
     * @var DataList
66
     */
67
    private $citationItems;
0 ignored issues
show
Coding Style introduced by
Private member variable "citationItems" must be prefixed with an underscore
Loading history...
68
69
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
70
     * @var ArrayList
71
     */
72
    private $results;
0 ignored issues
show
Coding Style introduced by
Private member variable "results" must be prefixed with an underscore
Loading history...
73
74
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
75
     * @var Root
76
     */
77
    private $root;
0 ignored issues
show
Coding Style introduced by
Private member variable "root" must be prefixed with an underscore
Loading history...
78
79
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
80
     * @var GlobalOptions
81
     */
82
    private $globalOptions;
0 ignored issues
show
Coding Style introduced by
Private member variable "globalOptions" must be prefixed with an underscore
Loading history...
83
84
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
85
     * @var BibliographyOptions
86
     */
87
    private $bibliographySpecificOptions;
0 ignored issues
show
Coding Style introduced by
Private member variable "bibliographySpecificOptions" must be prefixed with an underscore
Loading history...
88
89
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
90
     * @var CitationOptions
91
     */
92
    private $citationSpecificOptions;
0 ignored issues
show
Coding Style introduced by
Private member variable "citationSpecificOptions" must be prefixed with an underscore
Loading history...
93
94
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
95
     * @var RenderingState
96
     */
97
    private $renderingState;
0 ignored issues
show
Coding Style introduced by
Private member variable "renderingState" must be prefixed with an underscore
Loading history...
98
99
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
100
     * @var CssStyle
101
     */
102
    private $cssStyle;
0 ignored issues
show
Coding Style introduced by
Private member variable "cssStyle" must be prefixed with an underscore
Loading history...
103
104
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
105
     * @var Info
106
     */
107
    private $info;
0 ignored issues
show
Coding Style introduced by
Private member variable "info" must be prefixed with an underscore
Loading history...
108
109
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
110
     * @var array
111
     */
112
    protected $markupExtension = [];
113
114
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
115
     * @var bool
116
     */
117
    private $citationsAsArray = false;
0 ignored issues
show
Coding Style introduced by
Private member variable "citationsAsArray" must be prefixed with an underscore
Loading history...
118
119 142
    public function __construct($locale = null)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
120
    {
121 142
        if (!empty($locale)) {
122 135
            $this->locale = $locale;
123
        }
124
125 142
        $this->macros = new ArrayList();
126 142
        $this->citationItems = new DataList();
127 142
        $this->results = new ArrayList();
128 142
        $this->renderingState = new RenderingState(RenderingState::__default);
129 142
    }
130
131 47
    public function addMacro($key, $macro)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function addMacro()
Loading history...
132
    {
133 47
        $this->macros->add($key, $macro);
134 47
    }
135
136
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $key should have a doc-comment as per coding-style.
Loading history...
137
     * @param $key
1 ignored issue
show
Coding Style Documentation introduced by
Missing parameter name
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
138
     * @return Macro
1 ignored issue
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
139
     */
140 41
    public function getMacro($key)
141
    {
142 41
        return $this->macros->get($key);
143
    }
144
145
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
146
     * @param Locale $locale
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
147
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
148 142
    public function setLocale(Locale $locale)
149
    {
150 142
        $this->locale = $locale;
151 142
    }
152
153
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
154
     * @return Locale
155
     */
156 96
    public function getLocale()
157
    {
158 96
        return $this->locale;
159
    }
160
161
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
162
     * @return Bibliography
163
     */
164 56
    public function getBibliography()
165
    {
166 56
        return $this->bibliography;
167
    }
168
169
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
170
     * @param Bibliography $bibliography
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
171
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
172 63
    public function setBibliography(Bibliography $bibliography)
173
    {
174 63
        $this->bibliography = $bibliography;
175 63
    }
176
177
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
178
     * @return Citation
179
     */
180 133
    public function getCitation()
181
    {
182 133
        return $this->citation;
183
    }
184
185
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
186
     * @param Citation $citation
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
187
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
188 130
    public function setCitation($citation)
189
    {
190 130
        $this->citation = $citation;
191 130
    }
192
193
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $citationsAsArray should have a doc-comment as per coding-style.
Loading history...
194
     * @param $citationsAsArray
0 ignored issues
show
Coding Style Documentation introduced by
Missing parameter name
Loading history...
195
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
196 135
    public function setCitationsAsArray($citationsAsArray = true)
197
    {
198 135
        $this->citationsAsArray = $citationsAsArray;
199 135
    }
200
201 2
    public function isCitationsAsArray()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function isCitationsAsArray()
Loading history...
202
    {
203 2
        return $this->citationsAsArray;
204
    }
205
206 44
    public function setSorting($sorting)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setSorting()
Loading history...
207
    {
208 44
        $this->sorting = $sorting;
209 44
    }
210
211 131
    public function getSorting()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getSorting()
Loading history...
212
    {
213 131
        return $this->sorting;
214
    }
215
216
    /**
217
     * return the render mode (citation|bibliography)
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
218
     * @return string
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
219
     */
220 139
    public function getMode()
221
    {
222 139
        return $this->mode;
223
    }
224
225
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
226
     * @param string $mode
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
227
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
228 131
    public function setMode($mode)
229
    {
230 131
        $this->mode = $mode;
231 131
    }
232
233
    /**
234
     * returns true if the render mode is set to citation
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
235
     * @return bool
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
236
     */
237 91
    public function isModeCitation()
238
    {
239 91
        return $this->mode === "citation";
240
    }
241
242
    /**
243
     * returns true if the render mode is set to bibliography
0 ignored issues
show
Coding Style introduced by
Doc comment short description must start with a capital letter
Loading history...
244
     * @return bool
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
245
     */
246 131
    public function isModeBibliography()
247
    {
248 131
        return $this->mode === "bibliography";
249
    }
250
251
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
252
     * @return DataList
253
     */
254 88
    public function getCitationItems()
255
    {
256 88
        return $this->citationItems;
257
    }
258
259
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
260
     * @param DataList $citationItems
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
261
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
262 58
    public function setCitationItems(&$citationItems)
263
    {
264 58
        $this->citationItems = $citationItems;
265 58
    }
266
267
    public function hasCitationItems()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function hasCitationItems()
Loading history...
268
    {
269
        return ($this->citationItems->count() > 0);
270
    }
271
272
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
273
     * @return ArrayList
274
     */
275
    public function getMacros()
276
    {
277
        return $this->macros;
278
    }
279
280
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
281
     * @return ArrayList
282
     */
283 131
    public function getResults()
284
    {
285 131
        return $this->results;
286
    }
287
288
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
289
     * @return Root
290
     */
291 135
    public function getRoot()
292
    {
293 135
        return $this->root;
294
    }
295
296
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
297
     * @param Root $root
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
298
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
299 135
    public function setRoot(Root $root)
300
    {
301 135
        $this->root = $root;
302 135
    }
303
304
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
305
     * @return GlobalOptions
306
     */
307 89
    public function getGlobalOptions()
308
    {
309 89
        return $this->globalOptions;
310
    }
311
312
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
313
     * @param GlobalOptions $globalOptions
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
314
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
315 135
    public function setGlobalOptions(GlobalOptions $globalOptions)
316
    {
317 135
        $this->globalOptions = $globalOptions;
318 135
    }
319
320
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
321
     * @return RenderingState
322
     */
323 108
    public function getRenderingState()
324
    {
325 108
        return $this->renderingState;
326
    }
327
328
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
329
     * @param RenderingState|string $renderingState
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
330
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
331 47
    public function setRenderingState(RenderingState $renderingState)
332
    {
333 47
        $this->renderingState = $renderingState;
334 47
    }
335
336
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
337
     * @return BibliographyOptions
338
     */
339 134
    public function getBibliographySpecificOptions()
340
    {
341 134
        return $this->bibliographySpecificOptions;
342
    }
343
344
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
345
     * @param BibliographyOptions $bibliographySpecificOptions
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
346
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
347 63
    public function setBibliographySpecificOptions(BibliographyOptions $bibliographySpecificOptions)
348
    {
349 63
        $this->bibliographySpecificOptions = $bibliographySpecificOptions;
350 63
    }
351
352
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
353
     * @return CitationOptions
354
     */
355
    public function getCitationSpecificOptions()
356
    {
357
        return $this->citationSpecificOptions;
358
    }
359
360
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
361
     * @param CitationOptions $citationSpecificOptions
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
362
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
363 130
    public function setCitationSpecificOptions(CitationOptions $citationSpecificOptions)
364
    {
365 130
        $this->citationSpecificOptions = $citationSpecificOptions;
366 130
    }
367
368
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
369
     * @param CssStyle $cssStyle
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
370
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
371 3
    public function setCssStyle(CssStyle $cssStyle)
372
    {
373 3
        $this->cssStyle = $cssStyle;
374 3
    }
375
376
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
377
     * @return CssStyle
378
     */
379 3
    public function getCssStyle()
380
    {
381 3
        return $this->cssStyle;
382
    }
383
384 128
    public function setInfo(Info $info)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setInfo()
Loading history...
385
    {
386 128
        $this->info = $info;
387 128
    }
388
389 1
    public function getInfo()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getInfo()
Loading history...
390
    {
391 1
        return $this->info;
392
    }
393
394
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
395
     * @return array
396
     */
397 135
    public function getMarkupExtension()
398
    {
399 135
        return $this->markupExtension;
400
    }
401
402
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
403
     * @param array $markupExtension
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
404
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
405 135
    public function setMarkupExtension($markupExtension)
406
    {
407 135
        $this->markupExtension = $markupExtension;
408
    }
409
}