搜索某个服务中以case开头的方法名字 代码记录
搜索某个服务中以case开头的方法名字 代码记录
<?php
namespace App\Services;
class SLWCaseService
{
public function caseLogin1()
{
}
public function caseLogin2()
{
}
}
public function showCase(Request $request)
{
$reflection = new ReflectionClass(SLWCaseService::class);
$methods = $reflection->getMethods();
// 筛选出以 "case" 开头的方法
$caseMethods = array_filter($methods, function($method) {
return strpos($method->name, 'case') === 0;
});
// 获取方法名称
$caseMethodNames = array_map(function($method) {
return $method->name;
}, $caseMethods);
return [
'data'=>array_values($caseMethodNames)
];
}
本作品采用《CC 协议》,转载必须注明作者和本文链接