Source Code Docs

ParsesLinkIndex
in package

Parse the linkIndex.yml file which is used to determine the order the MarkdownPageCollection::class collection for pages in the sidebar.

Table of Contents

$filePath  : string
Path where the index is stored.
$index  : array<string|int, mixed>
The created Index array where the key is the numerical index and the value is the slug.
__construct()  : mixed
Construct the class
findIndexOfSlug()  : int|false
Get the index of a slug.
getIndexOfSlug()  : int|false
Static shorthand to get the index from a slag.
parseYamlToArray()  : array<string|int, mixed>
Stupidly simple and fast YAML list parser

Properties

$filePath

Path where the index is stored.

private string $filePath

Usually /resources/docs/linkIndex.yml

$index

The created Index array where the key is the numerical index and the value is the slug.

private array<string|int, mixed> $index

Methods

__construct()

Construct the class

public __construct() : mixed
Tags
throws
Exception

if link index cannot be found

Return values
mixed

findIndexOfSlug()

Get the index of a slug.

public findIndexOfSlug(string $slug[, int|bool $default = false ]) : int|false

Optionally specify the return value if a slug does not exist in the linkIndex.yml

Parameters
$slug : string

to search

$default : int|bool = false

return value

Return values
int|false

returns found value, or the fallback

getIndexOfSlug()

Static shorthand to get the index from a slag.

public static getIndexOfSlug(string $slug[, int|bool $default = false ]) : int|false
Parameters
$slug : string

to search

$default : int|bool = false

return value if the slug does not exist in the index

Return values
int|false

parseYamlToArray()

Stupidly simple and fast YAML list parser

public parseYamlToArray() : array<string|int, mixed>
Tags
author

Caen De Silva

Parses the yaml index file into an array where the key is the index and the value is the slug

Benchmarks on AMD Ryzen 7 1800X 8 Cores (Built in PHP server) 10 000 iterations off reading a yaml file with 1000 random entries Total time 3.1478400230 seconds Function average 0.3147840023 milliseconds (0.000314784002ms per line) Max memory usage: 2 mb

Return values
array<string|int, mixed>

Search results