These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Werkspot\Enum\Util; |
||
3 | |||
4 | class ClassNameConverter |
||
5 | { |
||
6 | /** |
||
7 | * In: ServicePro\SomeCommand |
||
8 | * Out: service_pro.some_command |
||
9 | * |
||
10 | * @param string $className |
||
11 | * @return string |
||
12 | */ |
||
13 | 2 | public static function convertClassNameToServiceName($className) |
|
14 | { |
||
15 | // Namespace 'directories' should be '.', like 'ServicePro\Foo' => 'ServicePro.Foo' |
||
0 ignored issues
–
show
|
|||
16 | 2 | $className = str_replace('\\', '.', $className); |
|
17 | |||
18 | // 'ServicePro.Foo' => 'service_pro._foo' |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
19 | 2 | $serviceName = lcfirst($className); |
|
20 | 2 | $serviceName = preg_replace('/([A-Z])/', '_$1', $serviceName); |
|
21 | |||
22 | // 'service_pro._foo' => 'service_pro.foo' |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
23 | 2 | $serviceName = str_replace('._', '.', $serviceName); |
|
24 | 2 | return strtolower($serviceName); |
|
25 | } |
||
26 | |||
27 | /** |
||
28 | * In: service_pro.some_command |
||
29 | * Out: ServicePro\SomeCommand |
||
30 | * |
||
31 | * @param string $serviceName |
||
32 | * @return string |
||
33 | */ |
||
34 | public static function convertServiceNameToClassName($serviceName) |
||
35 | { |
||
36 | // Namespace 'directories' should be '.', like 'service_pro.foo_class' => 'service_pro\Foo_class' |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
37% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
37 | $className = preg_replace_callback('/\.([a-z])/', function($c) { return '\\' . ucfirst($c[1]); }, $serviceName); |
||
38 | |||
39 | // 'service_pro\Foo_class' => 'ServicePro\FooClass' |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
40 | $className = preg_replace_callback('/_([a-z])/', function($c) { return ucfirst($c[1]); }, $className); |
||
41 | 2 | return ucfirst($className); |
|
42 | } |
||
43 | |||
44 | /** |
||
45 | * In: Some\Namespace\And\Class |
||
46 | * Out: Class |
||
47 | * |
||
48 | * @param string $className |
||
49 | * @return string |
||
50 | */ |
||
51 | 8 | public static function stripNameSpace($className) |
|
52 | { |
||
53 | 8 | return preg_replace('|.+\\\\|', '', $className); |
|
54 | } |
||
55 | } |
||
56 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.