-
Notifications
You must be signed in to change notification settings - Fork 308
/
MethodReflectionNamingFilter.php
34 lines (29 loc) · 1.35 KB
/
MethodReflectionNamingFilter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php declare(strict_types=1);
namespace ApiGen\Element\Latte\Filter;
use ApiGen\Contract\Templating\FilterProviderInterface;
use ApiGen\Reflection\Contract\Reflection\Class_\ClassMethodReflectionInterface;
use ApiGen\Reflection\Contract\Reflection\Interface_\InterfaceMethodReflectionInterface;
use ApiGen\Reflection\Contract\Reflection\Trait_\TraitMethodReflectionInterface;
final class MethodReflectionNamingFilter implements FilterProviderInterface
{
/**
* @return callable[]
*/
public function getFilters(): array
{
return [
// use in .latte: {$method|prettyMethodName}
'prettyMethodName' => function ($methodReflection) {
if ($methodReflection instanceof ClassMethodReflectionInterface) {
return $methodReflection->getDeclaringClassName() . '::' . $methodReflection->getName() . '()';
}
if ($methodReflection instanceof InterfaceMethodReflectionInterface) {
return $methodReflection->getDeclaringInterfaceName() . '::' . $methodReflection->getName() . '()';
}
if ($methodReflection instanceof TraitMethodReflectionInterface) {
return $methodReflection->getDeclaringTraitName() . '::' . $methodReflection->getName() . '()';
}
}
];
}
}