PHP Class Webiny\Component\StdLib\StdObject\StringObject\StringObject

This is a helper class for working with strings.
Inheritance: extends Webiny\Component\StdLib\StdObject\AbstractStdObject, implements ArrayAccess, use trait ManipulatorTrait, use trait ValidatorTrait
Show file Open project: Webiny/Framework Class Usage Examples

Protected Properties

Property Type Description
$value string

Public Methods

Method Description
__construct ( string | integer $value ) Constructor.
__toString ( ) : string To string implementation.
length ( ) : integer Get the length of the current string.
offsetExists ( mixed $offset ) : boolean (PHP 5 >= 5.0.0)
Whether a offset exists
offsetGet ( mixed $offset ) : mixed (PHP 5 >= 5.0.0)
Offset to retrieve
offsetSet ( mixed $offset, mixed $value ) : void (PHP 5 >= 5.0.0)
Offset to set
offsetUnset ( mixed $offset ) : void (PHP 5 >= 5.0.0)
Offset to unset
subStringCount ( string $string, null | integer $offset, null | integer $length = null ) : integer Get number of string occurrences in current string.
wordCount ( integer $format ) : mixed | ArrayObject Get the number of words in the string.

Method Details

__construct() public method

Set standard object value.
public __construct ( string | integer $value )
$value string | integer A string from which the StringObject instance will be created.

__toString() public method

To string implementation.
public __toString ( ) : string
return string Current string.

length() public method

Get the length of the current string.
public length ( ) : integer
return integer Length of current string.

offsetExists() public method

(PHP 5 >= 5.0.0)
Whether a offset exists
public offsetExists ( mixed $offset ) : boolean
$offset mixed

An offset to check for.

return boolean true on success or false on failure.

The return value will be casted to boolean if non-boolean was returned.

offsetGet() public method

(PHP 5 >= 5.0.0)
Offset to retrieve
public offsetGet ( mixed $offset ) : mixed
$offset mixed

The offset to retrieve.

return mixed Can return all value types.

offsetSet() public method

(PHP 5 >= 5.0.0)
Offset to set
public offsetSet ( mixed $offset, mixed $value ) : void
$offset mixed

The offset to assign the value to.

$value mixed

The value to set.

return void

offsetUnset() public method

(PHP 5 >= 5.0.0)
Offset to unset
public offsetUnset ( mixed $offset ) : void
$offset mixed

The offset to unset.

return void

subStringCount() public method

Get number of string occurrences in current string.
public subStringCount ( string $string, null | integer $offset, null | integer $length = null ) : integer
$string string String to search for
$offset null | integer The offset where to start counting
$length null | integer The maximum length after the specified offset to search for the substring. It outputs a warning if the offset plus the length is greater than the haystack length.
return integer

wordCount() public method

Get the number of words in the string.
public wordCount ( integer $format ) : mixed | ArrayObject
$format integer Specify the return format: 0 - return number of words 1 - return an ArrayObject containing all the words found inside the string 2 - returns an ArrayObject, where the key is the numeric position of the word inside the string and the value is the actual word itself
return mixed | Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject An ArrayObject or integer, based on the wanted $format, with the stats about the words in the string.

Property Details

$value protected property

protected string $value
return string