Completed
Push — master ( 888d29...e13826 )
by Sebastian
06:20
created

Context::getLocale()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/*
3
 * This file is a part of HDS (HeBIS Discovery System). HDS is an 
4
 * extension of the open source library search engine VuFind, that 
5
 * allows users to search and browse beyond resources. More 
6
 * Information about VuFind you will find on http://www.vufind.org
7
 * 
8
 * Copyright (C) 2016 
9
 * HeBIS Verbundzentrale des HeBIS-Verbundes 
10
 * Goethe-Universität Frankfurt / Goethe University of Frankfurt
11
 * http://www.hebis.de
12
 * 
13
 * This program is free software; you can redistribute it and/or
14
 * modify it under the terms of the GNU General Public License
15
 * as published by the Free Software Foundation; either version 2
16
 * of the License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
 * GNU General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU General Public License
24
 * along with this program; if not, write to the Free Software
25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
 */
27
28
namespace Seboettg\CiteProc;
29
use Seboettg\CiteProc\Locale\Locale;
30
use Seboettg\CiteProc\Style\Bibliography;
31
use Seboettg\CiteProc\Style\Citation;
32
use Seboettg\CiteProc\Style\Macro;
33
use Seboettg\CiteProc\Style\Sort\Sort;
34
use Seboettg\Collection\ArrayList;
35
36
37
/**
38
 * Class Context
39
 * @package Seboettg\CiteProc
40
 *
41
 * @author Sebastian Böttger <[email protected]>
42
 */
43
class Context
44
{
45
    /**
46
     * @var ArrayList
47
     */
48
    private $macros;
49
50
    /**
51
     * @var Locale
52
     */
53
    private $locale;
54
55
    /**
56
     * @var Bibliography
57
     */
58
    private $bibliography;
59
60
    /**
61
     * @var Citation
62
     */
63
    private $citation;
64
65
    /**
66
     * @var Sort
67
     */
68
    private $sorting;
69
70
    /**
71
     * @var string
72
     */
73
    private $mode;
74
75
    /**
76
     * @var ArrayList
77
     */
78
    private $citationItems;
79
80
    public function __construct($locale = null)
81
    {
82
        if (!empty($locale)) {
83
            $this->locale = $locale;
84
        }
85
86
        $this->macros = new ArrayList();
87
        $this->citationItems = 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 string
164
     */
165
    public function getMode()
166
    {
167
        return $this->mode;
168
    }
169
170
    /**
171
     * @param string $mode
172
     */
173
    public function setMode($mode)
174
    {
175
        $this->mode = $mode;
176
    }
177
178
    public function isModeCitation()
179
    {
180
        return $this->mode === "citation";
181
    }
182
183
    public function isModeBibliography()
184
    {
185
        return $this->mode === "bibliography";
186
    }
187
188
    /**
189
     * @return ArrayList
190
     */
191
    public function getCitationItems()
192
    {
193
        return $this->citationItems;
194
    }
195
196
    /**
197
     * @param ArrayList $citationItems
198
     */
199
    public function setCitationItems($citationItems)
200
    {
201
        $this->citationItems = $citationItems;
202
    }
203
204
    public function hasCitationItems()
205
    {
206
        return (count($this->citationItems) > 0);
207
    }
208
}