Francis Besset 9328c98935 Add 'src/BeSimple/SoapBundle/' from commit 'e99f707b105c0a0472260d8d42a5a14a7fb7a211'
git-subtree-dir: src/BeSimple/SoapBundle
git-subtree-mainline: 9a8d23fa23302486c56f1521a267c65a04eb8b87
git-subtree-split: e99f707b105c0a0472260d8d42a5a14a7fb7a211
2013-07-19 17:00:11 +02:00

49 lines
1.3 KiB
PHP

<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\Util;
/**
* String provides utility methods for strings.
*
* @author Christian Kerl <christian-kerl@web.de>
*/
class String
{
/**
* Checks if a string starts with a given string.
*
* @param string $str A string
* @param string $substr A string to check against
*
* @return bool True if str starts with substr
*/
public static function startsWith($str, $substr)
{
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
return $substr == substr($str, 0, strlen($substr));
}
}
/**
* Checks if a string ends with a given string.
*
* @param string $str A string
* @param string $substr A string to check against
*
* @return bool True if str ends with substr
*/
public static function endsWith($str, $substr)
{
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
return $substr == substr($str, strlen($str) - strlen($substr));
}
}
}