final class Badges

Reads and writes the badge rows that carry a card's kind, status, origin, category and labels.

A badge is an image whose alt text is the value. Its role comes from the image title, or from the path of a static shields.io badge, and is a label otherwise.

Properties§

public array<string, array<string, array{url: string, title: ?string}>> $images = []

Methods§

public static function isParagraph(Node $node): bool

Tells whether a block is a badge row.

Parameters

$nodeNodeThe block

Returns

bool True for a paragraph starting with an image
Test cases 1
Called from 1
Calls 1
  • method-call Node::firstChild() line 37
public function read(Node $node, stdClass $item): void

Reads a badge row into the item.

Parameters

$nodeNodeThe badge row
$itemstdClassThe item being read

Throws

InvalidInputException When the row holds anything but images, a value is empty, repeated or contradicts its static image
Test cases 6
Called from 1
Calls 9
public static function field(string $url, string|null $title): string

Decides which field a badge sets.

Parameters

$urlstringThe image URL
$titlestring|nullThe image title

Returns

string kind, status, origin, category or label

Throws

InvalidInputException When the title names another field
Test cases 2
Called from 1
Calls 4
public static function render(
    string $field,
    string $value,
    array{url: string, title: ?string}|null $image,
): string

Writes a badge.

Parameters

$fieldstringThe field the badge sets
$valuestringThe value
$imagearray{url: string, title: ?string}|nullThe image read for this value, or null for a new static badge

Returns

string The Markdown image
Test cases 1
Called from 2
Calls 4

Test cases 18§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 10
Other tests reaching this symbol 8

Relations§

Instantiated in 1
Static calls 3
Method calls 1