You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
47 lines
885 B
47 lines
885 B
<?php
|
|
|
|
namespace AlibabaCloud\Client\Support;
|
|
|
|
/**
|
|
* Class Stringy
|
|
*
|
|
* @package AlibabaCloud\Client\Support
|
|
*/
|
|
class Stringy
|
|
{
|
|
|
|
private static function _value($value, $default = '')
|
|
{
|
|
return null === $value ? $default : $value;
|
|
}
|
|
|
|
/**
|
|
* @param string $str
|
|
* @param string $substr
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function contains($str, $substr)
|
|
{
|
|
return false !== strpos(self::_value($str), self::_value($substr));
|
|
}
|
|
|
|
/**
|
|
* @param string $str
|
|
* @param string $substr
|
|
*
|
|
* @return bool
|
|
*/
|
|
public static function endsWith($str, $substr)
|
|
{
|
|
$str = self::_value($str);
|
|
$substr = self::_value($substr);
|
|
$length = \strlen($substr);
|
|
if (!$length) {
|
|
return true;
|
|
}
|
|
|
|
return substr($str, -$length) === $substr;
|
|
}
|
|
|
|
}
|
|
|