PrefixSuffix
PrefixSuffix class. Handles prefixes and suffixes in page filenames. Prefixes can be dates or numbers, and suffixes are typically language codes.
Table of Contents
Constants
- PREFIX_PATTERN = '(|.*\/)(([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])|[0-9]+)(-|_)(.*)'
- SUFFIX_PATTERN = '(.*)\.' . \Cecil\Config::LANG_CODE_PATTERN
Methods
- getPrefix() : string|null
- Returns the prefix if exists.
- getSuffix() : string|null
- Returns the suffix if exists.
- hasPrefix() : bool
- Returns true if the string contains a prefix.
- hasSuffix() : bool
- Returns true if the string contains a suffix.
- sub() : string
- Returns string without the prefix and the suffix (if exists).
- subPrefix() : string
- Returns string without the prefix (if exists).
- get() : string|null
- Returns the prefix or the suffix if exists.
- getPattern() : string
- Returns expreg pattern by $type.
- has() : bool
- Returns true if the string contains a prefix or a suffix.
Constants
PREFIX_PATTERN
public
mixed
PREFIX_PATTERN
= '(|.*\/)(([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])|[0-9]+)(-|_)(.*)'
SUFFIX_PATTERN
public
mixed
SUFFIX_PATTERN
= '(.*)\.' . \Cecil\Config::LANG_CODE_PATTERN
Methods
getPrefix()
Returns the prefix if exists.
public
static getPrefix(string $string) : string|null
Parameters
- $string : string
Return values
string|nullgetSuffix()
Returns the suffix if exists.
public
static getSuffix(string $string) : string|null
Parameters
- $string : string
Return values
string|nullhasPrefix()
Returns true if the string contains a prefix.
public
static hasPrefix(string $string) : bool
Parameters
- $string : string
Return values
boolhasSuffix()
Returns true if the string contains a suffix.
public
static hasSuffix(string $string) : bool
Parameters
- $string : string
Return values
boolsub()
Returns string without the prefix and the suffix (if exists).
public
static sub(string $string) : string
Parameters
- $string : string
Return values
stringsubPrefix()
Returns string without the prefix (if exists).
public
static subPrefix(string $string) : string
Parameters
- $string : string
Return values
stringget()
Returns the prefix or the suffix if exists.
protected
static get(string $string, string $type) : string|null
Parameters
- $string : string
- $type : string
Return values
string|nullgetPattern()
Returns expreg pattern by $type.
protected
static getPattern(string $type) : string
Parameters
- $type : string
Tags
Return values
stringhas()
Returns true if the string contains a prefix or a suffix.
protected
static has(string $string, string $type) : bool
Parameters
- $string : string
- $type : string