PHP Trait Webiny\Component\StdLib\StdObject\StringObject\ValidatorTrait

Inheritance: use trait Webiny\Component\StdLib\StdObject\StdObjectValidatorTrait
Show file Open project: Webiny/Framework

Public Methods

Method Description
contains ( string | StringObject $needle ) : boolean Checks if a string contains the given $char.
containsAny ( array | ArrayObjec\ArrayObject $needle ) : boolean Checks if a string contains any of the given $char.
endsWith ( string | StringObject $string ) : boolean Checks if the current string ends with the given $string.
equals ( string | StringObject $string ) : boolean Check if $string is equal to current string.
longerThan ( integer $num, boolean $inclusive = false ) : boolean Checks if the string length is great than the given length.
startsWith ( string | StringObject $string ) : boolean Checks if the current string starts with the given $string.
stringPosition ( string $string, integer $offset ) : integer | boolean Returns the position of the given $string inside the current string object.

Method Details

contains() public method

If the $char is present, true is returned. If you wish to match a string to a regular expression use StringObject:match().
public contains ( string | StringObject $needle ) : boolean
$needle string | StringObject String you wish to check if it exits within the current string.
return boolean True if current string contains the $needle. Otherwise false is returned.

containsAny() public method

If any of given $char is present, true is returned.
public containsAny ( array | ArrayObjec\ArrayObject $needle ) : boolean
$needle array | ArrayObjec\ArrayObject Array of characters you wish to check
return boolean True if current string contains the $needle. Otherwise false is returned.

endsWith() public method

Checks if the current string ends with the given $string.
public endsWith ( string | StringObject $string ) : boolean
$string string | StringObject String to check.
return boolean If current string ends with $string, true is returned, otherwise false.

equals() public method

Note that this comparison is case sensitive and binary safe.
public equals ( string | StringObject $string ) : boolean
$string string | StringObject String to compare.
return boolean True if current string is equal to $string. Otherwise false is returned.

longerThan() public method

Checks if the string length is great than the given length.
public longerThan ( integer $num, boolean $inclusive = false ) : boolean
$num integer Length against which you wish to check.
$inclusive boolean Do you want the check to be inclusive or not. Default is false (not inclusive).
return boolean If current string size is longer than the given $num, true is returned, otherwise false.

startsWith() public method

Checks if the current string starts with the given $string.
public startsWith ( string | StringObject $string ) : boolean
$string string | StringObject String to check.
return boolean If current string starts with $string, true is returned, otherwise false.

stringPosition() public method

Boolean false is returned if the $string is not present inside the current string. NOTE: Use type validation check in order no to mistake the position '0' (zero) for (bool) false.
public stringPosition ( string $string, integer $offset ) : integer | boolean
$string string
$offset integer
return integer | boolean If $string is contained within the current string, the position of $string is returned, otherwise false.