Documentation

Sanitize
in package

Sanitize identifiers of PHP keywords

Override methods to customize how PHP keywords (and HTML are handled coming from the OpenAPI specification).

Table of Contents

Properties

$htmlConverter  : HtmlConverter
$instance  : Sanitize|null
$reserved  : ReservedWords

Methods

clean()  : string
Make an identifer safe to use
getInstance()  : Sanitize
Sanitize is a singleton object
isSafe()  : bool
Is an identifier safe to use (i.e. not a PHP keyword)?
rename()  : string
Rename an $identifer
stripHtml()  : string|null
Convert raw HTML to Markdown
__construct()  : mixed
Singleton

Properties

$htmlConverter

private HtmlConverter $htmlConverter

$reserved

private ReservedWords $reserved

Methods

clean()

Make an identifer safe to use

public clean(string $name) : string
APIYes
Parameters
$name : string

The identifier to clean

Return values
string

A version of the identifier renamed (if necessary) to not be a PHP keyword

getInstance()

Sanitize is a singleton object

public static getInstance() : Sanitize
APIYes
Return values
Sanitize

Singleton instance

isSafe()

Is an identifier safe to use (i.e. not a PHP keyword)?

public isSafe(string $name) : bool
APIYes
Parameters
$name : string

The identifier to test

Return values
bool

rename()

Rename an $identifer

public rename(string $name) : string
APIYes

Hook to override to change the naming schema (e.g. a specific keyword to the identifier)

Default is to append _ to the end of the identifier

Parameters
$name : string

The identifier to be renamed

Return values
string

A renamed version of the identifier

stripHtml()

Convert raw HTML to Markdown

public stripHtml(string $html) : string|null
Parameters
$html : string

A string that potentially contains HTML

Return values
string|null

$html with any HTML converted to Markdown

__construct()

Singleton

private __construct() : mixed

        
On this page

Search results