Str
in package
Tags
Table of Contents
Properties
- $inflector : Inflector|null
Methods
- addSuffix() : string
- Ensures that the given string ends with the given suffix. If the string already contains the suffix, it's not added twice. It's case-insensitive (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'FooCommand').
- areClassesAlphabetical() : bool
- asCamelCase() : string
- asClassName() : string
- Transforms the given string into the format commonly used by PHP classes, (e.g. `app:do_this-and_that` -> `AppDoThisAndThat`) but it doesn't check the validity of the class name.
- asCommand() : string
- asEventMethod() : string
- asFilePath() : string
- asHumanWords() : string
- asLowerCamelCase() : string
- asRouteName() : string
- asRoutePath() : string
- asSnakeCase() : string
- asTwigVariable() : string
- Transforms the given string into the format commonly used by Twig variables (e.g. `BlogPostType` -> `blog_post_type`).
- getNamespace() : string
- getRandomTerm() : string
- getShortClassName() : string
- hasSuffix() : bool
- Looks for suffixes in strings in a case-insensitive way.
- isValidPhpVariableName() : bool
- Checks if the given name is a valid PHP variable name.
- pluralCamelCaseToSingular() : string
- removeSuffix() : string
- Ensures that the given string doesn't end with the given suffix. If the string contains the suffix multiple times, only the last one is removed.
- singularCamelCaseToPluralCamelCase() : string
- getInflector() : Inflector
- pluralize() : string
- singularize() : string
Properties
$inflector
private
static Inflector|null
$inflector
= null
Methods
addSuffix()
Ensures that the given string ends with the given suffix. If the string already contains the suffix, it's not added twice. It's case-insensitive (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'FooCommand').
public
static addSuffix(string $value, string $suffix) : string
Parameters
- $value : string
- $suffix : string
Return values
stringareClassesAlphabetical()
public
static areClassesAlphabetical(string $class1, string $class2) : bool
Parameters
- $class1 : string
- $class2 : string
Return values
boolasCamelCase()
public
static asCamelCase(string $str) : string
Parameters
- $str : string
Return values
stringasClassName()
Transforms the given string into the format commonly used by PHP classes, (e.g. `app:do_this-and_that` -> `AppDoThisAndThat`) but it doesn't check the validity of the class name.
public
static asClassName(string $value[, string $suffix = '' ]) : string
Parameters
- $value : string
- $suffix : string = ''
Return values
stringasCommand()
public
static asCommand(string $value) : string
Parameters
- $value : string
Return values
stringasEventMethod()
public
static asEventMethod(string $eventName) : string
Parameters
- $eventName : string
Return values
stringasFilePath()
public
static asFilePath(string $value) : string
Parameters
- $value : string
Return values
stringasHumanWords()
public
static asHumanWords(string $variableName) : string
Parameters
- $variableName : string
Return values
stringasLowerCamelCase()
public
static asLowerCamelCase(string $str) : string
Parameters
- $str : string
Return values
stringasRouteName()
public
static asRouteName(string $value) : string
Parameters
- $value : string
Return values
stringasRoutePath()
public
static asRoutePath(string $value) : string
Parameters
- $value : string
Return values
stringasSnakeCase()
public
static asSnakeCase(string $value) : string
Parameters
- $value : string
Return values
stringasTwigVariable()
Transforms the given string into the format commonly used by Twig variables (e.g. `BlogPostType` -> `blog_post_type`).
public
static asTwigVariable(string $value) : string
Parameters
- $value : string
Return values
stringgetNamespace()
public
static getNamespace(string $fullClassName) : string
Parameters
- $fullClassName : string
Return values
stringgetRandomTerm()
public
static getRandomTerm() : string
Return values
stringgetShortClassName()
public
static getShortClassName(string $fullClassName) : string
Parameters
- $fullClassName : string
Return values
stringhasSuffix()
Looks for suffixes in strings in a case-insensitive way.
public
static hasSuffix(string $value, string $suffix) : bool
Parameters
- $value : string
- $suffix : string
Return values
boolisValidPhpVariableName()
Checks if the given name is a valid PHP variable name.
public
static isValidPhpVariableName( $name) : bool
Parameters
Tags
Return values
boolpluralCamelCaseToSingular()
public
static pluralCamelCaseToSingular(string $camelCase) : string
Parameters
- $camelCase : string
Return values
stringremoveSuffix()
Ensures that the given string doesn't end with the given suffix. If the string contains the suffix multiple times, only the last one is removed.
public
static removeSuffix(string $value, string $suffix) : string
It's case-insensitive (e.g. value: 'Foocommand' suffix: 'Command' -> result: 'Foo'.
Parameters
- $value : string
- $suffix : string
Return values
stringsingularCamelCaseToPluralCamelCase()
public
static singularCamelCaseToPluralCamelCase(string $camelCase) : string
Parameters
- $camelCase : string
Return values
stringgetInflector()
private
static getInflector() : Inflector
Return values
Inflectorpluralize()
private
static pluralize(string $word) : string
Parameters
- $word : string
Return values
stringsingularize()
private
static singularize(string $word) : string
Parameters
- $word : string