Passed
Push — master ( 661b73...ccb1dd )
by Sebastian
08:54 queued 05:17
created

getSubsequentAuthorSubstitute()   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 0
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) 2017 Sebastian Böttger.
7
 * @license     https://opensource.org/licenses/MIT
8
 */
9
10
namespace Seboettg\CiteProc\Style\Options;
11
12
use SimpleXMLElement;
13
14
/**
15
 * Class GlobalOptionsTrait
16
 * @package Seboettg\CiteProc\Style
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
17
 * @author Sebastian Böttger <[email protected]>
1 ignored issue
show
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 1
Loading history...
18
 */
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...
19
class BibliographyOptions
20
{
21
22
    /**
23
     * If set, the value of this attribute replaces names in a bibliographic entry that also occur in the preceding
24
     * entry. The exact method of substitution depends on the value of the subsequent-author-substitute-rule attribute.
25
     * Substitution is limited to the names of the first cs:names element rendered. (Bibliography-specific option)
26
     *
27
     * @var string
28
     */
29
    private $subsequentAuthorSubstitute;
0 ignored issues
show
Coding Style introduced by
Private member variable "subsequentAuthorSubstitute" must be prefixed with an underscore
Loading history...
30
31
    /**
32
     * Specifies when and how names are substituted as a result of subsequent-author-substitute.
33
     * (Bibliography-specific option)
34
     *
35
     * @var SubsequentAuthorSubstituteRule
36
     */
37
    private $subsequentAuthorSubstituteRule;
0 ignored issues
show
Coding Style introduced by
Private member variable "subsequentAuthorSubstituteRule" must be prefixed with an underscore
Loading history...
38
39
    /**
40
     * If set to “true” (“false” is the default), bibliographic entries are rendered with hanging-indents.
41
     * @var 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...
42
     */
43
    private $hangingIndent = false;
0 ignored issues
show
Coding Style introduced by
Private member variable "hangingIndent" must be prefixed with an underscore
Loading history...
44
45
    /**
46
     * If set, subsequent lines of bibliographic entries are aligned along the second field. With “flush”, the first
47
     * field is flush with the margin. With “margin”, the first field is put in the margin, and subsequent lines are
48
     * aligned with the margin.
49
     * @var 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...
50
     */
51
    private $secondFieldAlign;
0 ignored issues
show
Coding Style introduced by
Private member variable "secondFieldAlign" must be prefixed with an underscore
Loading history...
52
53
    /**
54
     * Specifies vertical line distance. Defaults to “1” (single-spacing), and can be set to any positive integer to
55
     * specify a multiple of the standard unit of line height (e.g. “2” for double-spacing).
56
     * @var 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...
57
     */
58
    private $lineSpacing;
0 ignored issues
show
Coding Style introduced by
Private member variable "lineSpacing" must be prefixed with an underscore
Loading history...
59
60
    /**
61
     * Specifies vertical distance between bibliographic entries. By default (with a value of “1”), entries are
62
     * separated by a single additional line-height (as set by the line-spacing attribute). Can be set to any
63
     * non-negative integer to specify a multiple of this amount.
64
     * @var 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...
65
     */
66
    private $entrySpacing;
0 ignored issues
show
Coding Style introduced by
Private member variable "entrySpacing" must be prefixed with an underscore
Loading history...
67
68 64
    public function __construct(SimpleXMLElement $node)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
69
    {
70
71
        /** @var SimpleXMLElement $attribute */
3 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
72 64
        foreach ($node->attributes() as $attribute) {
73 55
            switch ($attribute->getName()) {
74 55
                case 'subsequent-author-substitute':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
75 10
                    $this->subsequentAuthorSubstitute = (string) $attribute;
76 10
                    break;
77 53
                case 'subsequent-author-substitute-rule':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
78 4
                    $this->subsequentAuthorSubstituteRule = new SubsequentAuthorSubstituteRule((string) $attribute);
79 4
                    break;
80 49
                case 'hanging-indent':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
81 27
                    $this->hangingIndent = "true" === (string) $attribute ? true : false;
0 ignored issues
show
Documentation Bug introduced by
The property $hangingIndent was declared of type string, but 'true' === (string)$attribute ? true : false is of type boolean. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
82 27
                    break;
83 49
                case 'second-field-align':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
84 9
                    $this->secondFieldAlign = (string) $attribute;
85 9
                    break;
86 49
                case 'line-spacing':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
87 19
                    $this->lineSpacing = (string) $attribute;
88 19
                    break;
89 49
                case 'entry-spacing':
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 12 spaces, found 16
Loading history...
90 55
                    $this->entrySpacing = (string) $attribute;
91
            }
92
        }
93 64
        if (empty($this->subsequentAuthorSubstituteRule)) {
94 60
            $this->subsequentAuthorSubstituteRule = new SubsequentAuthorSubstituteRule("complete-all");
95
        }
96 64
    }
97
98
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
99
     * @return string
100
     */
101 57
    public function getSubsequentAuthorSubstitute()
102
    {
103 57
        return $this->subsequentAuthorSubstitute;
104
    }
105
106
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
107
     * @param string $subsequentAuthorSubstitute
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
108
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
109
    public function setSubsequentAuthorSubstitute($subsequentAuthorSubstitute)
110
    {
111
        $this->subsequentAuthorSubstitute = $subsequentAuthorSubstitute;
112
    }
113
114
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
115
     * @return SubsequentAuthorSubstituteRule
116
     */
117 57
    public function getSubsequentAuthorSubstituteRule()
118
    {
119 57
        return $this->subsequentAuthorSubstituteRule;
120
    }
121
122
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
123
     * @param SubsequentAuthorSubstituteRule $subsequentAuthorSubstituteRule
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
124
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
125
    public function setSubsequentAuthorSubstituteRule($subsequentAuthorSubstituteRule)
126
    {
127
        $this->subsequentAuthorSubstituteRule = $subsequentAuthorSubstituteRule;
128
    }
129
130
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
131
     * @return string
132
     */
133 3
    public function getHangingIndent()
134
    {
135 3
        return $this->hangingIndent;
136
    }
137
138
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
139
     * @param string $hangingIndent
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
140
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
141
    public function setHangingIndent($hangingIndent)
142
    {
143
        $this->hangingIndent = $hangingIndent;
144
    }
145
146
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
147
     * @return string
148
     */
149 60
    public function getSecondFieldAlign()
150
    {
151 60
        return $this->secondFieldAlign;
152
    }
153
154
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
155
     * @param string $secondFieldAlign
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
156
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
157
    public function setSecondFieldAlign($secondFieldAlign)
158
    {
159
        $this->secondFieldAlign = $secondFieldAlign;
160
    }
161
162
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
163
     * @return string
164
     */
165 3
    public function getLineSpacing()
166
    {
167 3
        return $this->lineSpacing;
168
    }
169
170
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
171
     * @param string $lineSpacing
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
172
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
173
    public function setLineSpacing($lineSpacing)
174
    {
175
        $this->lineSpacing = $lineSpacing;
176
    }
177
178
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
179
     * @return string
180
     */
181 3
    public function getEntrySpacing()
182
    {
183 3
        return $this->entrySpacing;
184
    }
185
186
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
187
     * @param string $entrySpacing
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
188
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
189
    public function setEntrySpacing($entrySpacing)
190
    {
191
        $this->entrySpacing = $entrySpacing;
192
    }
193
194
195
}