Assert\Assertion::string PHP Method

string() public static method

Assert that value is a string
public static string ( mixed $value, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$message string | null
$propertyPath string | null
return boolean
    public static function string($value, $message = null, $propertyPath = null)
    {
        if (!is_string($value)) {
            $message = sprintf($message ?: 'Value "%s" expected to be string, type %s given.', static::stringify($value), gettype($value));
            throw static::createException($value, $message, static::INVALID_STRING, $propertyPath);
        }
        return true;
    }

Usage Example

コード例 #1
0
ファイル: XmlPath.php プロジェクト: metasyntactical/xml-tools
 private function setPath($path)
 {
     Assertion::string($path);
     Assertion::regex($path, '|(?mi-Us)^(/[a-zA-Z][a-zA-Z0-9_-]*)+(/@[a-zA-Z][a-zA-Z0-9_-]*)?$|');
     $this->path = $path;
     return $this;
 }
All Usage Examples Of Assert\Assertion::string