Conditions | 3 |
Paths | 4 |
Total Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
26 | public static function formatForAnnotation(SignalsAnnotation $annotation, $class) |
||
27 | { |
||
28 | $shortName = (new ReflectionClass($annotation))->getShortName(); |
||
29 | $type = preg_replace('~Annotation$~', '', $shortName); |
||
30 | $typeName = $annotation->getMeta()->type()->name; |
||
31 | $name = $annotation->name; |
||
32 | |||
33 | // Always available params |
||
34 | $params = [ |
||
35 | $type, |
||
36 | $typeName, |
||
37 | ]; |
||
38 | |||
39 | // Prepare first part of message |
||
40 | if (empty($class)) |
||
41 | { |
||
42 | $msg = 'Could not resolve class name'; |
||
43 | } |
||
44 | else |
||
45 | { |
||
46 | array_unshift($params, $class); |
||
47 | $msg = 'Class `%s` not found'; |
||
48 | } |
||
49 | |||
50 | // Prepare location of bogus annotation |
||
51 | if ($name === $typeName) |
||
52 | { |
||
53 | $msgOn = 'for `@%s` annotation on `%s`'; |
||
54 | } |
||
55 | else |
||
56 | { |
||
57 | $params[] = $name; |
||
58 | $msgOn = 'for `@%s` annotation on `%s::%s`'; |
||
59 | } |
||
60 | $msg = implode(' ', [$msg, $msgOn]); |
||
61 | return vsprintf($msg, $params); |
||
62 | } |
||
63 | |||
65 |