Refactored TDF processing PHP code to confirm to new TDF format

This commit is contained in:
Nav
2024-02-09 23:30:47 +00:00
parent 09a5be91fd
commit c563443737
58 changed files with 1877 additions and 1762 deletions

View File

@@ -0,0 +1,23 @@
<?php
namespace Targets\TargetDescriptionFiles\Services;
class StringService
{
public function tryStringToInt(?string $value): ?int
{
if ($value === null || strlen($value) === 0) {
return null;
}
return stristr($value, '0x') !== false ? (int) hexdec($value) : (int) $value;
}
public function tryIntToHex(?int $value, int $pad = 0): string
{
if ($value === null) {
return '';
}
return '0x' . str_pad(strtoupper(dechex($value)), $pad, '0', STR_PAD_LEFT);
}
}