Code cleanup, no functional changes
This commit is contained in:
@@ -3,17 +3,21 @@
|
||||
/**
|
||||
* Calculate CCITT-CRC16 checksum
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
if (! function_exists('crc16')) {
|
||||
function crc16($data): int
|
||||
{
|
||||
$crc = 0x0000;
|
||||
for ($i = 0; $i < strlen($data); $i++) {
|
||||
$x = (($crc >> 8) ^ ord($data[$i])) & 0xFF;
|
||||
$x ^= $x >> 4;
|
||||
$crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF;
|
||||
}
|
||||
return $crc;
|
||||
}
|
||||
function crc16($data): int
|
||||
{
|
||||
$crc = 0x0000;
|
||||
for ($i = 0; $i < strlen($data); $i++) {
|
||||
$x = (($crc >> 8) ^ ord($data[$i])) & 0xFF;
|
||||
$x ^= $x >> 4;
|
||||
$crc = (($crc << 8) ^ ($x << 12) ^ ($x << 5) ^ $x) & 0xFFFF;
|
||||
}
|
||||
return $crc;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,20 +93,20 @@ if (! function_exists('timew')) {
|
||||
* + 04 bits 10th Sec
|
||||
* = 32 (2 bits free)
|
||||
*
|
||||
* @param \Carbon\Carbon|null $time
|
||||
* @param Carbon|null $time
|
||||
* @return int
|
||||
*/
|
||||
function timew(\Carbon\Carbon $time=NULL): int
|
||||
function timew(Carbon $time=NULL): int
|
||||
{
|
||||
static $delay = 0;
|
||||
|
||||
// If we are not passed a time, we'll use the time now
|
||||
if (! $time) {
|
||||
// In case we are called twice, we'll delay 1/10th second so we have a unique result.
|
||||
if (\Carbon\Carbon::now()->getPreciseTimestamp(1) == $delay)
|
||||
if (Carbon::now()->getPreciseTimestamp(1) === $delay)
|
||||
usleep(100000);
|
||||
|
||||
$time = \Carbon\Carbon::now();
|
||||
$time = Carbon::now();
|
||||
}
|
||||
|
||||
$delay = $time->getPreciseTimestamp(1);
|
||||
@@ -124,12 +128,12 @@ if (! function_exists('dwtime')) {
|
||||
*
|
||||
* @param int $time
|
||||
* @param int|null $year
|
||||
* @return \Carbon\Carbon
|
||||
* @return Carbon
|
||||
*/
|
||||
function wtime(int $time,int $year=NULL): \Carbon\Carbon
|
||||
function wtime(int $time,int $year=NULL): Carbon
|
||||
{
|
||||
if (! $year)
|
||||
$year = \Carbon\Carbon::now()->year;
|
||||
$year = Carbon::now()->year;
|
||||
|
||||
// Does the time have milli seconds?
|
||||
if ($time > pow(2,26)-1) {
|
||||
@@ -154,7 +158,7 @@ if (! function_exists('dwtime')) {
|
||||
|
||||
$month = ($time & 0x1f);
|
||||
|
||||
return \Carbon\Carbon::create($year,$month,$day,$hr,$min,$sec+$milli/10);
|
||||
return Carbon::create($year,$month,$day,$hr,$min,$sec+$milli/10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,7 +166,7 @@ if (! function_exists('optimize_path')) {
|
||||
/**
|
||||
* This will optimize an array of paths to show the smallest number of characters
|
||||
*/
|
||||
function optimize_path(\Illuminate\Support\Collection $path): \Illuminate\Support\Collection
|
||||
function optimize_path(Collection $path): Collection
|
||||
{
|
||||
$cur = NULL;
|
||||
$result = collect();
|
||||
|
Reference in New Issue
Block a user