Webiny\Component\StdLib\StdObject\StringObject\ValidatorTrait::stringPosition PHP Method

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.
    public function stringPosition($string, $offset = 0)
    {
        $string = StdObjectWrapper::toString($string);
        if (!$this->isNumber($offset)) {
            throw new StringObjectException(StringObjectException::MSG_INVALID_ARG, ['$offset', 'integer']);
        }
        // we double-cast the $string param to string, because integer is also a string, but in stripos function integer
        // can cause unwanted mismatches if it's not strictly casted to string
        return stripos($this->val(), (string) $string, $offset);
    }