Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Details
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace pvc\html\elements_structured;
4
5use pvc\html\elements\Details as BaseDetails;
6use pvc\html\factory\HtmlFactory;
7use pvc\interfaces\html\attribute\AttributeInterface;
8use pvc\struct\tree\dto\TreenodeDto;
9use pvc\struct\tree\node\NodeIdFactory;
10
11/**
12 * must have a summary element as its first child
13 */
14class Details extends BaseDetails
15{
16    /**
17     * @param  string  $name
18     * @param  array<string>  $attributes
19     * @param  HtmlFactory  $htmlFactory
20     *
21     * @throws \Psr\Container\ContainerExceptionInterface
22     * @throws \Psr\Container\NotFoundExceptionInterface
23     * @throws \pvc\html\err\InvalidTagNameException
24     */
25    public function __construct(
26        string $name,
27        array $attributes,
28        HtmlFactory $htmlFactory
29    ) {
30        parent::__construct($name, $attributes, $htmlFactory);
31
32        /**
33         * add the summary element as the first child
34         */
35        $node = $this->getDomNode();
36        $domElement = $this->htmlFactory->makeElement('summary');
37        $childDto = new TreenodeDto(NodeIdFactory::getNextNodeId(), $node->getNodeId(), null);
38        $childNode = $node->getTree()->getTreenodeFactory()->makeNode();
39        $childNode->hydrate($childDto);
40    }
41}