| Server IP : 116.202.121.150 / Your IP : 216.73.217.103 Web Server : Apache System : Linux server5.febas.net 6.1.0-51-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.177-1 (2026-07-16) x86_64 User : k9887-1 ( 1171) PHP Version : 8.2.33 Disable Function : show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen, system, shell_exec, passthru, popen, proc_open, exec MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/k9887-1/htdocs/_fisch/wp-content/plugins/duplicator/src/Libs/Snap/ |
Upload File : |
<?php
/**
*
* @package Duplicator
* @copyright (c) 2021, Snapcreek LLC
*
*/
namespace Duplicator\Libs\Snap;
class SnapString
{
/**
* Return true or false in string
*
* @param mixed $b input value
*
* @return string
*/
public static function boolToString($b)
{
return ($b ? 'true' : 'false');
}
/**
* Truncate string and add ellipsis
*
* @param string $s string to truncate
* @param int $maxWidth max length
*
* @return string
*/
public static function truncateString($s, $maxWidth)
{
if (strlen($s) > $maxWidth) {
$s = substr($s, 0, $maxWidth - 3) . '...';
}
return $s;
}
/**
* Returns true if the $haystack string starts with the $needle
*
* @param string $haystack The full string to search in
* @param string $needle The string to for
*
* @return bool Returns true if the $haystack string starts with the $needle
*/
public static function startsWith($haystack, $needle)
{
return (strpos($haystack, $needle) === 0);
}
/**
* Returns true if the $haystack string end with the $needle
*
* @param string $haystack The full string to search in
* @param string $needle The string to for
*
* @return bool Returns true if the $haystack string starts with the $needle
*/
public static function endsWith($haystack, $needle)
{
$length = strlen($needle);
if ($length == 0) {
return true;
}
return (substr($haystack, -$length) === $needle);
}
/**
* Returns true if the $needle is found in the $haystack
*
* @param string $haystack The full string to search in
* @param string $needle The string to for
*
* @return bool
*/
public static function contains($haystack, $needle)
{
$pos = strpos($haystack, $needle);
return ($pos !== false);
}
/**
* Implode array key values to a string
*
* @param string $glue separator
* @param array $pieces array fo implode
* @param string $format format
*
* @return string
*/
public static function implodeKeyVals($glue, $pieces, $format = '%s="%s"')
{
$strList = array();
foreach ($pieces as $key => $value) {
if (is_scalar($value)) {
$strList[] = sprintf($format, $key, $value);
} else {
$strList[] = sprintf($format, $key, print_r($value, true));
}
}
return implode($glue, $strList);
}
/**
* Replace last occurrence
*
* @param string $search The value being searched for
* @param string $replace The replacement value that replaces found search values
* @param string $str The string or array being searched and replaced on, otherwise known as the haystack
* @param boolean $caseSensitive Whether the replacement should be case sensitive or not
*
* @return string
*/
public static function strLastReplace($search, $replace, $str, $caseSensitive = true)
{
$pos = $caseSensitive ? strrpos($str, $search) : strripos($str, $search);
if (false !== $pos) {
$str = substr_replace($str, $replace, $pos, strlen($search));
}
return $str;
}
/**
* Check if passed string have html tags
*
* @param string $string input string
*
* @return boolean
*/
public static function isHTML($string)
{
return ($string != strip_tags($string));
}
}