kintVariableData.class.php in Devel 8
File
kint/kint/inc/kintVariableData.class.php
View source
<?php
class kintVariableData {
public $type;
public $access;
public $name;
public $operator;
public $size;
public $extendedValue;
public $value;
public $_alternatives;
private static $_supportedCharsets = array(
'UTF-8',
'Windows-1252',
'euc-jp',
);
protected static function _detectEncoding($value) {
$ret = null;
if (function_exists('mb_detect_encoding')) {
$mbDetected = mb_detect_encoding($value);
if ($mbDetected === 'ASCII') {
return 'ASCII';
}
}
if (!function_exists('iconv')) {
return !empty($mbDetected) ? $mbDetected : 'UTF-8';
}
$md5 = md5($value);
foreach (Kint::$charEncodings as $encoding) {
if (md5(@iconv($encoding, $encoding, $value)) === $md5) {
return $encoding;
}
}
return 'ASCII';
}
protected static function _isSequential(array $array) {
return array_keys($array) === range(0, count($array) - 1);
}
protected static function _strlen($string, $encoding = null) {
if (function_exists('mb_strlen')) {
$encoding or $encoding = self::_detectEncoding($string);
return mb_strlen($string, $encoding);
}
else {
return strlen($string);
}
}
protected static function _substr($string, $start, $end, $encoding = null) {
if (function_exists('mb_substr')) {
$encoding or $encoding = self::_detectEncoding($string);
return mb_substr($string, $start, $end, $encoding);
}
else {
return substr($string, $start, $end);
}
}
}