Completed
Push — master ( a22bfe...2e3ab0 )
by Mike
02:35
created

Figure::processSub()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 5
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace phpDocumentor\Guides\RestructuredText\Directives;
6
7
use phpDocumentor\Guides\Nodes\FigureNode;
8
use phpDocumentor\Guides\Nodes\ImageNode;
9
use phpDocumentor\Guides\Nodes\Node;
10
use phpDocumentor\Guides\RestructuredText\Parser;
11
12
/**
13
 * Renders an image, example :
14
 *
15
 * .. figure:: image.jpg
16
 *      :width: 100
17
 *      :title: An image
18
 *
19
 *      Here is an awesome caption
20
 */
21
class Figure extends SubDirective
22
{
23
    public function getName() : string
24
    {
25
        return 'figure';
26
    }
27
28
    /**
29
     * @param string[] $options
30
     */
31
    public function processSub(
32
        Parser $parser,
33
        ?Node $document,
34
        string $variable,
35
        string $data,
36
        array $options
37
    ) : ?Node {
38
        return new FigureNode(
39
            new ImageNode($parser->getEnvironment()->relativeUrl($data)),
40
            $document
41
        );
42
    }
43
}
44