mirror of
https://github.com/YGGverse/yo-tools-php.git
synced 2026-03-31 17:55:32 +00:00
init Snap class
This commit is contained in:
parent
577cf83f6f
commit
3622e0d67f
1 changed files with 38 additions and 0 deletions
38
src/Snap.php
Normal file
38
src/Snap.php
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Yggverse\YoTools;
|
||||||
|
|
||||||
|
class Snap
|
||||||
|
{
|
||||||
|
public static function getTimeLast(array $files): int
|
||||||
|
{
|
||||||
|
$time = [];
|
||||||
|
|
||||||
|
foreach ($files as $file)
|
||||||
|
{
|
||||||
|
if (!str_ends_with($file, '.tar.gz'))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$time[] = preg_replace(
|
||||||
|
'/^([\d]+)\.tar\.gz$/',
|
||||||
|
'$1',
|
||||||
|
basename(
|
||||||
|
$file
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($time)
|
||||||
|
{
|
||||||
|
return max(
|
||||||
|
$time
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue