This commit is contained in:
Nuno Maduro
2020-05-11 18:38:30 +02:00
commit de2929077b
112 changed files with 6211 additions and 0 deletions

32
src/Support/Str.php Normal file
View File

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Pest\Support;
/**
* @internal
*/
final class Str
{
/**
* Checks if the given `$target` starts with the given `$search`.
*/
public static function startsWith(string $target, string $search): bool
{
return substr($target, 0, strlen($search)) === $search;
}
/**
* Checks if the given `$target` ends with the given `$search`.
*/
public static function endsWith(string $target, string $search): bool
{
$length = strlen($search);
if ($length === 0) {
return true;
}
return substr($target, -$length) === $search;
}
}