1<?php
2
3/*
4 * This file is part of the league/commonmark package.
5 *
6 * (c) Colin O'Dell <colinodell@gmail.com>
7 * (c) Rezo Zero / Ambroise Maupate
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12
13declare(strict_types=1);
14
15namespace League\CommonMark\Extension\Footnote\Node;
16
17use League\CommonMark\Block\Element\AbstractBlock;
18use League\CommonMark\Cursor;
19use League\CommonMark\Reference\ReferenceInterface;
20
21/**
22 * @method children() AbstractBlock[]
23 */
24final class Footnote extends AbstractBlock
25{
26    /**
27     * @var FootnoteBackref[]
28     */
29    private $backrefs = [];
30
31    /**
32     * @var ReferenceInterface
33     */
34    private $reference;
35
36    public function __construct(ReferenceInterface $reference)
37    {
38        $this->reference = $reference;
39    }
40
41    public function canContain(AbstractBlock $block): bool
42    {
43        return true;
44    }
45
46    public function isCode(): bool
47    {
48        return false;
49    }
50
51    public function matchesNextLine(Cursor $cursor): bool
52    {
53        return false;
54    }
55
56    public function getReference(): ReferenceInterface
57    {
58        return $this->reference;
59    }
60
61    public function addBackref(FootnoteBackref $backref): self
62    {
63        $this->backrefs[] = $backref;
64
65        return $this;
66    }
67
68    /**
69     * @return FootnoteBackref[]
70     */
71    public function getBackrefs(): array
72    {
73        return $this->backrefs;
74    }
75}
76