@@ -73,8 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | if (CiteProc::getContext()->isModeBibliography()) { |
75 | 75 | if ($data instanceof DataList) { |
76 | - foreach ($data as $citationNumber => $item) { |
|
77 | - ++self::$numberOfCitedItems; |
|
76 | + foreach ($data as $citationNumber => $item) {++self::$numberOfCitedItems; |
|
78 | 77 | CiteProc::getContext()->getResults()->append($this->wrapBibEntry($this->renderSingle($item, $citationNumber))); |
79 | 78 | } |
80 | 79 | $ret .= implode($this->delimiter, CiteProc::getContext()->getResults()->toArray()); |
@@ -82,7 +81,7 @@ discard block |
||
82 | 81 | $ret .= $this->wrapBibEntry($this->renderSingle($data, $citationNumber)); |
83 | 82 | } |
84 | 83 | |
85 | - return "<div class=\"csl-bib-body\">".$ret."\n</div>"; |
|
84 | + return "<div class=\"csl-bib-body\">" . $ret . "\n</div>"; |
|
86 | 85 | |
87 | 86 | } else if (CiteProc::getContext()->isModeCitation()) { |
88 | 87 | if (is_array($data) || $data instanceof DataList) { |
@@ -51,6 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | private $parent; |
53 | 53 | |
54 | + /** |
|
55 | + * @param \Seboettg\CiteProc\Style\StyleElement $parent |
|
56 | + */ |
|
54 | 57 | public function __construct($node, $parent) |
55 | 58 | { |
56 | 59 | $this->parent = $parent; |
@@ -131,6 +134,9 @@ discard block |
||
131 | 134 | return self::$numberOfCitedItems; |
132 | 135 | } |
133 | 136 | |
137 | + /** |
|
138 | + * @param string $value |
|
139 | + */ |
|
134 | 140 | private function wrapBibEntry($value) |
135 | 141 | { |
136 | 142 | return "\n <div class=\"csl-entry\">" . $value . "</div>"; |
@@ -146,8 +146,7 @@ |
||
146 | 146 | $resultNames[] = $this->formatName($name, $rank); |
147 | 147 | } |
148 | 148 | } |
149 | - } |
|
150 | - else { |
|
149 | + } else { |
|
151 | 150 | $resultNames[] = $this->formatName($name, $rank); |
152 | 151 | } |
153 | 152 | } |
@@ -99,6 +99,9 @@ |
||
99 | 99 | $this->initDelimiterAttributes($node); |
100 | 100 | } |
101 | 101 | |
102 | + /** |
|
103 | + * @param integer $citationNumber |
|
104 | + */ |
|
102 | 105 | public function render($data, $citationNumber = null) |
103 | 106 | { |
104 | 107 | if (!$this->attributesInitialized) { |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | $lastName = null; |
114 | 114 | $resultNames = []; |
115 | 115 | $count = 0; |
116 | - $hasPreceding = CiteProc::getContext()->getCitationItems()->hasKey($citationNumber-1); |
|
116 | + $hasPreceding = CiteProc::getContext()->getCitationItems()->hasKey($citationNumber - 1); |
|
117 | 117 | |
118 | 118 | if ($hasPreceding) { |
119 | 119 | /** @var \stdClass $preceding */ |
120 | - $preceding = CiteProc::getContext()->getCitationItems()->get($citationNumber-1); |
|
120 | + $preceding = CiteProc::getContext()->getCitationItems()->get($citationNumber - 1); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | $subsequentSubstitution = CiteProc::getContext()->getCitationItems()->getSubsequentAuthorSubstitute(); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | which allows for advanced sorting. */ |
216 | 216 | |
217 | 217 | if ($this->form == 'count') { |
218 | - return (int)count($resultNames); |
|
218 | + return (int) count($resultNames); |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | return $text; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | if (count($this->nameParts) > 0) { |
235 | 235 | /** @var NamePart $namePart */ |
236 | 236 | foreach ($this->nameParts as $namePart) { |
237 | - $nameObj->{$namePart->getName()} = $namePart->render($name); |
|
237 | + $nameObj->{$namePart->getName()} = $namePart->render($name); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | { |
61 | 61 | /** @var \SimpleXMLElement $node */ |
62 | 62 | foreach ($locale as $node) { |
63 | - switch($node->getName()) { |
|
63 | + switch ($node->getName()) { |
|
64 | 64 | case 'style-options': |
65 | 65 | $this->optionsXml->add('options', $node); |
66 | 66 | foreach ($node->attributes() as $name => $value) { |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | } |
109 | 109 | break; |
110 | 110 | case 'date': |
111 | - $form = (string)$node["form"]; |
|
111 | + $form = (string) $node["form"]; |
|
112 | 112 | $this->dateXml->add($form, $node); |
113 | 113 | foreach ($node->children() as $child) { |
114 | 114 | $date = new \stdClass(); |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | $wordArray = explode(" ", $text); |
66 | 66 | |
67 | - array_walk($wordArray, function (&$word) { |
|
67 | + array_walk($wordArray, function(&$word) { |
|
68 | 68 | $word = ucfirst($word); |
69 | 69 | }); |
70 | 70 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | public static function capitalizeForTitle($titleString) |
75 | 75 | { |
76 | 76 | if (preg_match('/(.+[^\<\>][\.:\/;\?\!]\s?)([a-z])(.+)/', $titleString, $match)) { |
77 | - $titleString = $match[1].StringHelper::mb_ucfirst($match[2]).$match[3]; |
|
77 | + $titleString = $match[1] . StringHelper::mb_ucfirst($match[2]) . $match[3]; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $wordArray = explode(" ", $titleString); |
81 | 81 | |
82 | - array_walk($wordArray, function (&$word) { |
|
82 | + array_walk($wordArray, function(&$word) { |
|
83 | 83 | |
84 | 84 | $words = explode("-", $word); |
85 | 85 | if (count($words) > 1) { |
86 | - array_walk($words, function (&$w) { |
|
86 | + array_walk($words, function(&$w) { |
|
87 | 87 | $w = StringHelper::keepLowerCase($w) ? $w : StringHelper::mb_ucfirst($w); |
88 | 88 | }); |
89 | 89 | $word = implode("-", $words); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | public static function keepLowerCase($word) |
98 | 98 | { |
99 | - $lowerCase = in_array($word, self::PREPOSITIONS) || |
|
99 | + $lowerCase = in_array($word, self::PREPOSITIONS) || |
|
100 | 100 | in_array($word, self::ARTICLES) || |
101 | 101 | in_array($word, self::CONJUNCTIONS) || |
102 | 102 | in_array($word, self::ADJECTIVES); |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | foreach ($node->attributes() as $name => $value) { |
49 | 49 | if ('match' !== $name) { |
50 | - $this->constraints->append(Factory::createConstraint((string)$name, (string)$value)); |
|
50 | + $this->constraints->append(Factory::createConstraint((string) $name, (string) $value)); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 |
@@ -41,6 +41,9 @@ |
||
41 | 41 | */ |
42 | 42 | protected $parent; |
43 | 43 | |
44 | + /** |
|
45 | + * @param Choose $parent |
|
46 | + */ |
|
44 | 47 | public function __construct(\SimpleXMLElement $node, $parent) |
45 | 48 | { |
46 | 49 | $this->parent = $parent; |
@@ -79,6 +79,10 @@ |
||
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | + /** |
|
83 | + * @param string $render |
|
84 | + * @param string $original |
|
85 | + */ |
|
82 | 86 | private function keepNoCase($render, $original) |
83 | 87 | { |
84 | 88 | if (preg_match('/<span class=\"nocase\">(\p{L}+)<\/span>/i', $original, $match)) { |
@@ -50,6 +50,7 @@ |
||
50 | 50 | /** |
51 | 51 | * Bibliography constructor. |
52 | 52 | * @param \SimpleXMLElement $node |
53 | + * @param Root $parent |
|
53 | 54 | */ |
54 | 55 | public function __construct(\SimpleXMLElement $node, $parent) |
55 | 56 | { |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $parentStyleElement = ($context->isModeBibliography() ? $context->getBibliography() : $context->getCitation()); |
235 | 235 | } |
236 | 236 | |
237 | - } else if ($this instanceof StyleElement){ |
|
237 | + } else if ($this instanceof StyleElement) { |
|
238 | 238 | $parentStyleElement = $context->getRoot(); |
239 | 239 | } |
240 | 240 | |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | switch ($nameAttribute) { |
244 | 244 | case 'and': |
245 | 245 | if (!empty($attribute)) { |
246 | - $this->and = (string)$attribute; |
|
246 | + $this->and = (string) $attribute; |
|
247 | 247 | |
248 | 248 | } else if (!empty($parentStyleElement)) { //inherit from parent style |
249 | 249 | $this->and = $parentStyleElement->getAnd(); |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | break; |
252 | 252 | case 'delimiter-precedes-et-al': |
253 | 253 | if (!empty($attribute)) { |
254 | - $this->delimiterPrecedesEtAl = (string)$attribute; |
|
254 | + $this->delimiterPrecedesEtAl = (string) $attribute; |
|
255 | 255 | } else if (!empty($parentStyleElement)) { //inherit from parent style |
256 | 256 | $this->delimiterPrecedesEtAl = $parentStyleElement->getDelimiterPrecedesEtAl(); |
257 | 257 | } |
258 | 258 | break; |
259 | 259 | case 'delimiter-precedes-last': |
260 | 260 | if (!empty($attribute)) { |
261 | - $this->delimiterPrecedesLast = (string)$attribute; |
|
261 | + $this->delimiterPrecedesLast = (string) $attribute; |
|
262 | 262 | } else if (!empty($parentStyleElement)) { //inherit from parent style |
263 | 263 | $this->delimiterPrecedesLast = $parentStyleElement->getDelimiterPrecedesLast(); |
264 | 264 | } |
@@ -272,14 +272,14 @@ discard block |
||
272 | 272 | break; |
273 | 273 | case 'et-al-use-first': |
274 | 274 | if (!empty($attribute)) { |
275 | - $this->etAlUseFirst = intval((string)$attribute); |
|
275 | + $this->etAlUseFirst = intval((string) $attribute); |
|
276 | 276 | } else if (!empty($parentStyleElement)) { |
277 | 277 | $this->etAlUseFirst = $parentStyleElement->getEtAlUseFirst(); |
278 | 278 | } |
279 | 279 | break; |
280 | 280 | case 'et-al-subsequent-min': |
281 | 281 | if (!empty($attribute)) { |
282 | - $this->etAlSubsequentMin = intval((string)$attribute); |
|
282 | + $this->etAlSubsequentMin = intval((string) $attribute); |
|
283 | 283 | } else if (!empty($parentStyleElement)) { |
284 | 284 | $this->etAlSubsequentMin = $parentStyleElement->getEtAlSubsequentMin(); |
285 | 285 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | break; |
310 | 310 | case 'initialize-with': |
311 | 311 | if (!empty($attribute)) { |
312 | - $this->initializeWith = (string)$attribute; |
|
312 | + $this->initializeWith = (string) $attribute; |
|
313 | 313 | } else if (!empty($parentStyleElement)) { |
314 | 314 | $this->initializeWith = $parentStyleElement->getInitializeWith(); |
315 | 315 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | case 'name-form': |
332 | 332 | if ($this instanceof Root || $this instanceof StyleElement) { |
333 | 333 | if (!empty($attribute)) { |
334 | - $this->nameForm = (string)$attribute; |
|
334 | + $this->nameForm = (string) $attribute; |
|
335 | 335 | } else if (!empty($parentStyleElement)) { |
336 | 336 | $this->nameForm = $parentStyleElement->getNameForm(); |
337 | 337 | } |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | case 'form': |
341 | 341 | if ($this instanceof Name) { |
342 | 342 | if (!empty($attribute)) { |
343 | - $this->form = (string)$attribute; |
|
343 | + $this->form = (string) $attribute; |
|
344 | 344 | } else if (!empty($parentStyleElement)) { |
345 | 345 | $this->form = $parentStyleElement->getNameForm(); |
346 | 346 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | case 'name-delimiter': |
350 | 350 | if ($this instanceof Root || $this instanceof StyleElement) { |
351 | 351 | if (!empty($attribute)) { |
352 | - $this->nameDelimiter = (string)$attribute; |
|
352 | + $this->nameDelimiter = (string) $attribute; |
|
353 | 353 | } else if (!empty($parentStyleElement)) { |
354 | 354 | $this->nameDelimiter = $parentStyleElement->getNameDelimiter(); |
355 | 355 | } |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | case 'delimiter': |
359 | 359 | if ($this instanceof Name) { |
360 | 360 | if (!empty($attribute)) { |
361 | - $this->delimiter = (string)$attribute; |
|
361 | + $this->delimiter = (string) $attribute; |
|
362 | 362 | } else if (!empty($parentStyleElement)) { |
363 | 363 | $this->delimiter = $parentStyleElement->getNameDelimiter(); |
364 | 364 | } |
@@ -61,7 +61,7 @@ |
||
61 | 61 | * formatting attributes. |
62 | 62 | */ |
63 | 63 | case 'layout': |
64 | - $this->layout = new Layout($child, $this); |
|
64 | + $this->layout = new Layout($child, $this); |
|
65 | 65 | break; |
66 | 66 | |
67 | 67 | /* cs:citation and cs:bibliography may include a cs:sort child element before the cs:layout element to |