EtAl   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 3 1
A __construct() 0 13 3
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\Rendering\Name;
11
12
use Seboettg\CiteProc\CiteProc;
13
use Seboettg\CiteProc\Data\DataList;
14
use Seboettg\CiteProc\Rendering\Rendering;
15
use Seboettg\CiteProc\Styles\FormattingTrait;
16
use SimpleXMLElement;
17
use stdClass;
18
19
/**
20
 * Class EtAl
21
 * Et-al abbreviation, controlled via the et-al-... attributes (see Name), can be further customized with the optional
22
 * cs:et-al element, which must follow the cs:name element (if present). The term attribute may be set to either “et-al”
23
 * (the default) or to “and others” to use either term. The formatting attributes may also be used, for example to
24
 * italicize the “et-al” term.
25
 *
26
 * @package Seboettg\CiteProc\Rendering\Name
27
 *
28
 * @author Sebastian Böttger <[email protected]>
29
 */
30
class EtAl implements Rendering
31
{
32
    use FormattingTrait;
33
34
    private $term;
35
36
    public function __construct(SimpleXMLElement $node)
37
    {
38
        /**
39
         * @var SimpleXMLElement $attribute
40
         */
41
        foreach ($node->attributes() as $attribute) {
42
            switch ($attribute->getName()) {
43
                case 'term':
44
                    $this->term = (string) $attribute;
45
                    break;
46
            }
47
        }
48
        $this->initFormattingAttributes($node);
49
    }
50
51
    /**
52
     * @param  array|DataList|stdClass $data
53
     * @param  null $citationNumber
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $citationNumber is correct as it would always require null to be passed?
Loading history...
54
     * @return string
55
     */
56
    public function render($data, $citationNumber = null)
57
    {
58
        return $this->format(CiteProc::getContext()->getLocale()->filter('terms', $this->term)->single);
59
    }
60
}
61