StrTrait
+ Inheritance diagram for StrTrait:

Description

Character string expression manipulation.

Public Methods

Str concat (... $strings)
 Concatenate other strings. More...
 
Str hex ()
 Hex representation. More...
 
Predicate isEmpty ()
 Zero-length. More...
 
Num length ()
 Number of characters (not necessarily bytes). More...
 
Str lower ()
 Lowercase. More...
 
Str ltrim (string $chars=null)
 See StrTrait::trim(). More...
 
Num position (string $substring)
 Substring's position (1-based). More...
 
Str replace (string $search, string $replace)
 String replacement. More...
 
Str rtrim (string $chars=null)
 See StrTrait::trim(). More...
 
Num size ()
 Number of bytes (not necessarily characters). More...
 
Str substr (int $start, int $length=null)
 Substring. More...
 
Num toBase10 (int $from)
 Convert from an arbitrary base to base 10. More...
 
Str trim (string $chars=null)
 Trims whitespace (or other things) from both ends of the string. More...
 
Str upper ()
 Uppercase. More...
 
- Public Methods inherited from ValueTrait
Value coalesce (array $values)
 COALESCE($this, ...$values) More...
 
- Public Methods inherited from AggregateTrait
Num avg ()
 AVG($this) More...
 
Num avgDistinct ()
 AVG(DISTINCT $this) More...
 
Num count ()
 COUNT($this) More...
 
Num countDistinct ()
 COUNT(DISTINCT $this) More...
 
Str groupConcat (string $delimiter=',')
 GROUP_CONCAT($this) using a delimiter. More...
 
Num max ()
 MAX($this) More...
 
Num min ()
 MIN($this) More...
 
Num sum ()
 SUM($this) More...
 
Num sumDistinct ()
 SUM(DISTINCT $this) More...
 
- Public Methods inherited from ComparisonTrait
Predicate is ($arg)
 Null-safe type-strict equality. More...
 
Predicate isBetween ($min, $max)
 $this BETWEEN $min AND $max (inclusive) More...
 
Predicate isEqual ($arg)
 See Predicate::match(). More...
 
Predicate isFalse ()
 $this IS FALSE More...
 
Predicate isGt ($arg)
 $this > $arg, or driver-appropriate $this > ALL (SELECT ...) More...
 
Predicate isGtAny (Select $select)
 Driver-appropriate $this > ANY (SELECT ...) More...
 
Predicate isGte ($arg)
 $this >= $arg, or driver-appropriate $this >= ALL (SELECT ...) More...
 
Predicate isGteAny (Select $select)
 Driver-appropriate $this >= ANY (SELECT ...) More...
 
Predicate isLike (string $pattern)
 $this LIKE $pattern More...
 
Predicate isLt ($arg)
 $this < $arg, or driver-appropriate $this < ALL (SELECT ...) More...
 
Predicate isLtAny (Select $select)
 Driver-appropriate $this < ANY (SELECT ...) More...
 
Predicate isLte ($arg)
 $this <= $arg, or driver-appropriate $this <= ALL (SELECT ...) More...
 
Predicate isLteAny (Select $select)
 Driver-appropriate $this <= ANY (SELECT ...) More...
 
Predicate isNot ($arg)
 Null-safe type-strict inequality. More...
 
Predicate isNotBetween ($min, $max)
 $this NOT BETWEEN $min AND $max (inclusive) More...
 
Predicate isNotEqual ($arg)
 $this <> $arg or $this NOT IN ($arg) More...
 
Predicate isNotLike (string $pattern)
 $this NOT LIKE $pattern More...
 
Predicate isNotNull ()
 $this IS NOT NULL More...
 
Predicate isNotRegExp (string $pattern)
 $this NOT REGEXP $pattern More...
 
Predicate isNull ()
 $this IS NULL More...
 
Predicate isRegExp (string $pattern)
 $this REGEXP $pattern More...
 
Branch switch (array $values=[])
 CASE $this ... More...
 
- Public Methods inherited from BaseConversionTrait
Str toBase (int $from, int $to)
 Convert between arbitrary bases. More...
 
Str toBase16 (int $from=10)
 Convert from an arbitrary base to base 16. More...
 
Str toBase2 (int $from=10)
 Convert from an arbitrary base to base 2. More...
 
Str toBase8 (int $from=10)
 Convert from an arbitrary base to base 8. More...
 

Methods

◆ concat()

Str concat (   $strings)

Concatenate other strings.

Parameters
string|ValueInterface...$strings
Returns
Str

◆ hex()

Str hex ( )

Hex representation.

Returns
Str

◆ isEmpty()

Predicate isEmpty ( )

Zero-length.

Returns
Predicate

◆ length()

Num length ( )

Number of characters (not necessarily bytes).

See also
StrTrait::size()
Returns
Num

◆ lower()

Str lower ( )

Lowercase.

Returns
Str

◆ ltrim()

Str ltrim ( string  $chars = null)

See StrTrait::trim().

Parameters
null | string$chars
Returns
Str

◆ position()

Num position ( string  $substring)

Substring's position (1-based).

The position is 0 if the substring isn't found.

Parameters
string$substring
Returns
Num

◆ replace()

Str replace ( string  $search,
string  $replace 
)

String replacement.

Parameters
string$search
string$replace
Returns
Str

◆ rtrim()

Str rtrim ( string  $chars = null)

See StrTrait::trim().

Parameters
null | string$chars
Returns
Str

◆ size()

Num size ( )

Number of bytes (not necessarily characters).

Returns
Num

◆ substr()

Str substr ( int  $start,
int  $length = null 
)

Substring.

Parameters
int$start1-based, can be negative to start from the right.
null | int$length
Returns
Str

◆ toBase10()

Num toBase10 ( int  $from)

Convert from an arbitrary base to base 10.

Parameters
int$from
Returns
Num

◆ trim()

Str trim ( string  $chars = null)

Trims whitespace (or other things) from both ends of the string.

If $chars is given:

  • MySQL treats it as a leading/trailing string
  • SQLite treats it as individual characters (same as PHP)
See also
StrTrait::ltrim()
StrTrait::rtrim()
Parameters
null | string$chars
Returns
Str

◆ upper()

Str upper ( )

Uppercase.

Returns
Str