seboettg /
citeproc-php
| 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\Root\Root; |
||||||
| 16 | use Seboettg\CiteProc\Style\Options\BibliographyOptions; |
||||||
| 17 | use SimpleXMLElement; |
||||||
| 18 | |||||||
| 19 | /** |
||||||
| 20 | * Class Bibliography |
||||||
| 21 | * |
||||||
| 22 | * The cs:bibliography element describes the formatting of bibliographies, which list one or more bibliographic sources. |
||||||
| 23 | * The required cs:layout child element describes how each bibliographic entry should be formatted. cs:layout may be |
||||||
| 24 | * preceded by a cs:sort element, which can be used to specify how references within the bibliography should be sorted |
||||||
| 25 | * (see Sorting). |
||||||
| 26 | * |
||||||
| 27 | * @package Seboettg\CiteProc |
||||||
| 28 | * |
||||||
| 29 | * @author Sebastian Böttger <[email protected]> |
||||||
| 30 | */ |
||||||
| 31 | class Bibliography extends StyleElement |
||||||
| 32 | { |
||||||
| 33 | private $node; |
||||||
| 34 | |||||||
| 35 | /** |
||||||
| 36 | * Bibliography constructor. |
||||||
| 37 | * @param SimpleXMLElement $node |
||||||
| 38 | * @param Root $parent |
||||||
| 39 | * @throws InvalidStylesheetException |
||||||
| 40 | */ |
||||||
| 41 | public function __construct(SimpleXMLElement $node, Root $parent) |
||||||
| 42 | { |
||||||
| 43 | parent::__construct($node, $parent); |
||||||
| 44 | $this->node = $node; |
||||||
| 45 | $bibliographyOptions = new BibliographyOptions($node); |
||||||
| 46 | CiteProc::getContext()->setBibliographySpecificOptions($bibliographyOptions); |
||||||
| 47 | $this->initInheritableNameAttributes($node); |
||||||
| 48 | } |
||||||
| 49 | |||||||
| 50 | /** |
||||||
| 51 | * @param array|DataList $data |
||||||
| 52 | * @param int|null $citationNumber |
||||||
| 53 | * @return string |
||||||
| 54 | */ |
||||||
| 55 | public function render($data, $citationNumber = null) |
||||||
| 56 | { |
||||||
| 57 | if (!$this->attributesInitialized) { |
||||||
| 58 | $this->initInheritableNameAttributes($this->node); |
||||||
| 59 | } |
||||||
| 60 | $subsequentAuthorSubstitute = CiteProc::getContext() |
||||||
| 61 | ->getBibliographySpecificOptions() |
||||||
| 62 | ->getSubsequentAuthorSubstitute(); |
||||||
| 63 | |||||||
| 64 | $subsequentAuthorSubstituteRule = CiteProc::getContext() |
||||||
| 65 | ->getBibliographySpecificOptions() |
||||||
| 66 | ->getSubsequentAuthorSubstituteRule(); |
||||||
| 67 | |||||||
| 68 | if ($subsequentAuthorSubstitute !== null && !empty($subsequentAuthorSubstituteRule)) { |
||||||
| 69 | CiteProc::getContext() |
||||||
| 70 | ->getCitationData() |
||||||
| 71 | ->setSubsequentAuthorSubstitute($subsequentAuthorSubstitute); |
||||||
| 72 | CiteProc::getContext() |
||||||
| 73 | ->getCitationData() |
||||||
| 74 | ->setSubsequentAuthorSubstituteRule($subsequentAuthorSubstituteRule); |
||||||
| 75 | } |
||||||
| 76 | return $this->layout->render($data, $citationNumber); |
||||||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
It seems like
$citationNumber can also be of type integer; however, parameter $citationItems of Seboettg\CiteProc\Rendering\Layout::render() does only seem to accept Seboettg\Collection\Map\MapInterface, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
It seems like
$data can also be of type array; however, parameter $data of Seboettg\CiteProc\Rendering\Layout::render() does only seem to accept Seboettg\CiteProc\Data\DataList, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 77 | } |
||||||
| 78 | } |
||||||
| 79 |