1<?php
2
3/*
4 * This file is part of the league/commonmark package.
5 *
6 * (c) Colin O'Dell <colinodell@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace League\CommonMark\Extension\TableOfContents\Normalizer;
13
14use League\CommonMark\Block\Element\ListItem;
15use League\CommonMark\Extension\TableOfContents\Node\TableOfContents;
16
17final class FlatNormalizerStrategy implements NormalizerStrategyInterface
18{
19    /** @var TableOfContents */
20    private $toc;
21
22    public function __construct(TableOfContents $toc)
23    {
24        $this->toc = $toc;
25    }
26
27    public function addItem(int $level, ListItem $listItemToAdd): void
28    {
29        $this->toc->appendChild($listItemToAdd);
30    }
31}
32
33// Trigger autoload without causing a deprecated error
34\class_exists(TableOfContents::class);
35