Ai
1 Star 0 Fork 0

.何以致契阔/thinkphp 数据库迁移工具

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
NamespaceAwareTrait.php 1.69 KB
一键复制 编辑 原始数据 按行查看 历史
.何以致契阔 提交于 2024-10-08 09:46 +08:00 . pd
<?php
/**
* MIT License
* For full license information, please view the LICENSE file that was distributed with this source code.
*/
namespace Phinx\Config;
/**
* Trait implemented NamespaceAwareInterface.
*
* @package Phinx\Config
* @author Andrey N. Mokhov
*/
trait NamespaceAwareTrait
{
/**
* Gets the paths to search for migration files.
*
* @return string[]
*/
abstract public function getMigrationPaths(): array;
/**
* Gets the paths to search for seed files.
*
* @return string[]
*/
abstract public function getSeedPaths(): array;
/**
* Search $needle in $haystack and return key associate with him.
*
* @param string $needle Needle
* @param string[] $haystack Haystack
* @return string|null
*/
protected function searchNamespace(string $needle, array $haystack): ?string
{
$needle = realpath($needle);
$haystack = array_map('realpath', $haystack);
$key = array_search($needle, $haystack, true);
return is_string($key) ? trim($key, '\\') : null;
}
/**
* Get Migration Namespace associated with path.
*
* @param string $path Path
* @return string|null
*/
public function getMigrationNamespaceByPath(string $path): ?string
{
$paths = $this->getMigrationPaths();
return $this->searchNamespace($path, $paths);
}
/**
* Get Seed Namespace associated with path.
*
* @param string $path Path
* @return string|null
*/
public function getSeedNamespaceByPath(string $path): ?string
{
$paths = $this->getSeedPaths();
return $this->searchNamespace($path, $paths);
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/tlan_turing/turing-migration.git
git@gitee.com:tlan_turing/turing-migration.git
tlan_turing
turing-migration
thinkphp 数据库迁移工具
master

搜索帮助