You are here

public function TocFormatter::convertNumberToLetter in TOC API 8

Convert a number to a letter.

References:

Parameters

int $number: A number.

Return value

string The number converted to a letter.

Overrides TocFormatterInterface::convertNumberToLetter

1 call to TocFormatter::convertNumberToLetter()
TocFormatter::convertNumberToListTypeValue in src/TocFormatter.php
Convert a number to a selected type (alpha or roman).

File

src/TocFormatter.php, line 88

Class

TocFormatter
Defines a service for formatting a table of content's headers, numbering, and ids..

Namespace

Drupal\toc_api

Code

public function convertNumberToLetter($number) {
  static $letters = [
    'a',
    'b',
    'c',
    'd',
    'e',
    'f',
    'g',
    'h',
    'i',
    'j',
    'k',
    'l',
    'm',
    'n',
    'o',
    'p',
    'q',
    'r',
    's',
    't',
    'u',
    'v',
    'w',
    'x',
    'y',
    'z',
  ];
  return $letters[($number - 1) % 26];
}