Skip to content

Commit

Permalink
coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterOdin committed Nov 29, 2024
1 parent d117ee5 commit 7dc46d3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Phinx/Util/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public static function getCurrentTimestamp(?int $offset = null): string
return $dt->format(static::DATE_FORMAT);
}

/**
* Checks that the given timestamp is a unique prefix for any files in the given path.
*
* @param string $path Path to check
* @param string $timestamp Timestamp to check
* @return bool
*/
public static function isUniqueTimestamp(string $path, string $timestamp): bool
{
return !count(static::glob($path. DIRECTORY_SEPARATOR . $timestamp . '*.php'));
Expand Down Expand Up @@ -107,11 +114,18 @@ public static function getVersionFromFileName(string $fileName): int
return $value;
}

/**
* Given a string, convert it to snake_case.
*
* @param string $string String to convert
* @return string
*/
public static function toSnakeCase(string $string): string
{
$snake = function ($matches) {
return '_' . strtolower($matches[0]);
};

return preg_replace_callback('/\d+|[A-Z]/', $snake, $string);
}

Expand All @@ -121,7 +135,6 @@ public static function toSnakeCase(string $string): string
* '12345678901234_limit_resource_names_to_30_chars.php'.
*
* @deprecated Will be removed in 0.17.0
*
* @param string $className Class Name
* @return string
*/
Expand Down

0 comments on commit 7dc46d3

Please sign in to comment.