Passed
Push — master ( 121290...ef5b2f )
by Caen
06:26 queued 03:36
created

UsesFlattenedOutputPaths::getRouteKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Pages\Concerns;
6
7
use function basename;
8
use function unslash;
9
10
/**
11
 * @internal This trait is currently experimental and should not be relied upon outside of Hyde.
12
 *
13
 * This trait is used to flatten the output path of a page. This is only used for the documentation pages,
14
 * where all pages are output to the same directory, but where putting the page in a subdirectory will
15
 * create a nested navigation structure in the sidebar.
16
 *
17
 * @see https://hydephp.com/docs/master/documentation-pages#using-subdirectories
18
 */
19
trait UsesFlattenedOutputPaths
20
{
21
    /**
22
     * Get the route key for the page.
23
     *
24
     * Uses the identifier basename so nested pages are flattened.
25
     */
26
    public function getRouteKey(): string
27
    {
28
        return unslash(static::outputDirectory().'/'.basename($this->identifier));
29
    }
30
31
    /**
32
     * Get the path where the compiled page will be saved.
33
     *
34
     * Uses the identifier basename so nested pages are flattened.
35
     */
36
    public function getOutputPath(): string
37
    {
38
        return static::outputPath(basename($this->identifier));
39
    }
40
}
41