mirror of
https://github.com/PHPOffice/PhpSpreadsheet.git
synced 2026-09-19 06:26:48 +00:00
Use str_starts_with and str_ends_with instead
This commit is contained in:
@@ -265,7 +265,7 @@ class Value
|
||||
if (is_bool($value)) {
|
||||
return (int) $value;
|
||||
}
|
||||
if (is_string($value) && substr($value, 0, 1) === '#') {
|
||||
if (is_string($value) && str_starts_with($value, '#')) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +316,7 @@ abstract class Coordinate
|
||||
|
||||
$worksheet = $matches['worksheet'];
|
||||
if ($worksheet !== '') {
|
||||
if (substr($worksheet, 0, 1) === "'" && substr($worksheet, -1, 1) === "'") {
|
||||
if (str_starts_with($worksheet, "'") && str_ends_with($worksheet, "'")) {
|
||||
$worksheet = substr($worksheet, 1, -1);
|
||||
}
|
||||
$data['worksheet'] = strtolower($worksheet);
|
||||
|
||||
@@ -1129,7 +1129,7 @@ class Html extends BaseReader
|
||||
$styleArray = self::getStyleArray($attributes);
|
||||
|
||||
$src = $attributes['src'];
|
||||
if (substr($src, 0, 5) !== 'data:') {
|
||||
if (!str_starts_with($src, 'data:')) {
|
||||
$src = urldecode($src);
|
||||
}
|
||||
$width = isset($attributes['width']) ? (float) $attributes['width'] : ($styleArray['width'] ?? null);
|
||||
@@ -1195,13 +1195,13 @@ class Html extends BaseReader
|
||||
$arrayKey = trim($value[0]);
|
||||
$arrayValue = trim($value[1]);
|
||||
if ($arrayKey === 'width') {
|
||||
if (substr($arrayValue, -2) === 'px') {
|
||||
if (str_ends_with($arrayValue, 'px')) {
|
||||
$arrayValue = (string) (((float) substr($arrayValue, 0, -2)));
|
||||
} else {
|
||||
$arrayValue = (new CssDimension($arrayValue))->toUnit(CssDimension::UOM_PIXELS);
|
||||
}
|
||||
} elseif ($arrayKey === 'height') {
|
||||
if (substr($arrayValue, -2) === 'px') {
|
||||
if (str_ends_with($arrayValue, 'px')) {
|
||||
$arrayValue = substr($arrayValue, 0, -2);
|
||||
} else {
|
||||
$arrayValue = (new CssDimension($arrayValue))->toUnit(CssDimension::UOM_PIXELS);
|
||||
|
||||
@@ -64,7 +64,7 @@ class XmlScanner
|
||||
|
||||
private function findCharSet(string $xml): string
|
||||
{
|
||||
if (substr($xml, 0, 4) === "\x4c\x6f\xa7\x94") {
|
||||
if (str_starts_with($xml, "\x4c\x6f\xa7\x94")) {
|
||||
throw new Reader\Exception('EBCDIC encoding not permitted');
|
||||
}
|
||||
$encoding = Reader\Csv::guessEncodingBom('', $xml);
|
||||
|
||||
@@ -2430,7 +2430,7 @@ class Xlsx extends BaseReader
|
||||
$attrs = $rel->attributes() ?? [];
|
||||
$rid = (string) ($attrs['Id'] ?? '');
|
||||
$target = (string) ($attrs['Target'] ?? '');
|
||||
if ($rid === $id && substr($target, 0, 2) === '..') {
|
||||
if ($rid === $id && str_starts_with($target, '..')) {
|
||||
$target = 'xl' . substr($target, 2);
|
||||
$content = $this->getFromZipArchive($this->zip, $target);
|
||||
$docSheet->setBackgroundImage($content);
|
||||
|
||||
@@ -3411,7 +3411,7 @@ class Worksheet
|
||||
public static function unApostrophizeTitle(?string $title): string
|
||||
{
|
||||
$title ??= '';
|
||||
if ($title[0] === "'" && substr($title, -1) === "'") {
|
||||
if (str_starts_with($title, "'") && str_ends_with($title, "'")) {
|
||||
$title = str_replace("''", "'", substr($title, 1, -1));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user