Citation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A render() 0 6 2
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\Style;
11
12
use Seboettg\CiteProc\CiteProc;
13
use Seboettg\CiteProc\Data\DataList;
14
use Seboettg\CiteProc\Exception\InvalidStylesheetException;
15
use Seboettg\CiteProc\Style\Options\CitationOptions;
16
use Seboettg\Collection\ArrayList;
17
use Seboettg\Collection\Lists\ListInterface;
18
use Seboettg\Collection\Map\MapInterface;
19
use SimpleXMLElement;
20
21
/**
22
 * Class Citation
23
 *
24
 * The cs:citation element describes the formatting of citations, which consist of one or more references (“cites”) to
25
 * bibliographic sources. Citations appear in the form of either in-text citations (in the author (e.g. “[Doe]”),
26
 * author-date (“[Doe 1999]”), label (“[doe99]”) or number (“[1]”) format) or notes. The required cs:layout child
27
 * element describes what, and how, bibliographic data should be included in the citations (see Layout).
28
 *
29
 * @package Seboettg\CiteProc\Node\Style
30
 *
31
 * @author Sebastian Böttger <[email protected]>
32
 */
33
class Citation extends StyleElement
34
{
35
36
    private $node;
37
38
    /**
39
     * Citation constructor.
40
     * @param SimpleXMLElement $node
41
     * @param $parent
42
     * @throws InvalidStylesheetException
43
     */
44
    public function __construct(SimpleXMLElement $node, $parent)
45
    {
46
        parent::__construct($node, $parent);
47
        $citationOptions = new CitationOptions($node);
48
        CiteProc::getContext()->setCitationSpecificOptions($citationOptions);
49
        $this->node = $node;
50
    }
51
52
    public function render(DataList $data, MapInterface $citationItems)
53
    {
54
        if (!$this->attributesInitialized) {
55
            $this->initInheritableNameAttributes($this->node);
56
        }
57
        return $this->layout->render($data, $citationItems);
58
    }
59
}
60