1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Cerbero\LaravelEnum; |
6
|
|
|
|
7
|
|
|
use Cerbero\Enum\Enums as BaseEnums; |
8
|
|
|
use Cerbero\LaravelEnum\Actions\OnCall; |
9
|
|
|
use Closure; |
10
|
|
|
use UnitEnum; |
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* The enums manager. |
14
|
|
|
*/ |
15
|
|
|
final class Enums extends BaseEnums |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* The logic to resolve the translation key. |
19
|
|
|
* |
20
|
|
|
* @var ?Closure(UnitEnum $case, string $method): string |
21
|
|
|
*/ |
22
|
|
|
protected static ?Closure $translateFrom = null; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* The glob paths to find enums in. |
26
|
|
|
* |
27
|
|
|
* @var string[] |
28
|
|
|
*/ |
29
|
|
|
protected static array $paths = ['app/Enums']; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Handle the call to an inaccessible case method. |
33
|
|
|
* |
34
|
|
|
* @param array<array-key, mixed> $arguments |
|
|
|
|
35
|
|
|
*/ |
36
|
10 |
|
public static function handleCall(UnitEnum $case, string $name, array $arguments): mixed |
37
|
|
|
{ |
38
|
10 |
|
return (static::$onCall ?: new OnCall())($case, $name, $arguments); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Set the logic to resolve the translation key. |
43
|
|
|
* |
44
|
|
|
* @param callable(UnitEnum $case, string $method): string $callback |
45
|
|
|
*/ |
46
|
1 |
|
public static function translateFrom(callable $callback): void |
47
|
|
|
{ |
48
|
1 |
|
static::$translateFrom = $callback(...); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Retrieve the translation key for the given case. |
53
|
|
|
*/ |
54
|
6 |
|
public static function resolveTranslationKey(UnitEnum $case, ?string $method = null): string |
55
|
|
|
{ |
56
|
6 |
|
return static::$translateFrom |
57
|
1 |
|
? (static::$translateFrom)($case, (string) $method) |
58
|
6 |
|
: sprintf('enums.%s.%s%s', $case::class, $case->name, $method ? ".{$method}" : ''); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths