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

Citation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 28
ccs 10
cts 10
cp 1
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
/*
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\Style;
11
12
use Seboettg\CiteProc\CiteProc;
13
use Seboettg\CiteProc\Data\DataList;
14
use Seboettg\CiteProc\Style\Options\CitationOptions;
15
use Seboettg\Collection\ArrayList;
16
17
18
/**
19
 * Class Citation
20
 *
21
 * The cs:citation element describes the formatting of citations, which consist of one or more references (“cites”) to
22
 * bibliographic sources. Citations appear in the form of either in-text citations (in the author (e.g. “[Doe]”),
23
 * author-date (“[Doe 1999]”), label (“[doe99]”) or number (“[1]”) format) or notes. The required cs:layout child
24
 * element describes what, and how, bibliographic data should be included in the citations (see Layout).
25
 *
26
 * @package Seboettg\CiteProc\Node\Style
27
 *
28
 * @author Sebastian Böttger <[email protected]>
29
 */
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...
30
class Citation extends StyleElement
31
{
32
33
    private $node;
0 ignored issues
show
Coding Style introduced by
Private member variable "node" must be prefixed with an underscore
Loading history...
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $parent should have a doc-comment as per coding-style.
Loading history...
36
     * Citation constructor.
37
     * @param \SimpleXMLElement $node
2 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
38
     */
39 130
    public function __construct(\SimpleXMLElement $node, $parent)
40
    {
41 130
        parent::__construct($node, $parent);
42 130
        $citationOptions = new CitationOptions($node);
43 130
        CiteProc::getContext()->setCitationSpecificOptions($citationOptions);
44 130
        $this->node = $node;
45 130
    }
46
47
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
48
     * @param array|DataList $data
2 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
49
     * @param ArrayList $citationItems
3 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
50
     * @return string
1 ignored issue
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
51
     */
52 91
    public function render($data, $citationItems)
53
    {
54 91
        if (!$this->attributesInitialized) {
55 91
            $this->initInheritableNameAttributes($this->node);
56
        }
57 91
        return $this->layout->render($data, $citationItems);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->layout->re...($data, $citationItems) also could return the type array|string[] which is incompatible with the documented return type string.
Loading history...
58
    }
59
60
}