Conditions | 4 |
Paths | 4 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.074 |
Changes | 0 |
1 | <?php |
||
57 | 2 | public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { |
|
58 | |||
59 | 2 | $title = $semanticData->getSubject()->getTitle(); |
|
60 | |||
61 | 2 | if ( !$title->inNamespace( NS_USER ) ) { |
|
62 | return; |
||
63 | } |
||
64 | |||
65 | 2 | $user = $this->appFactory->newUserFromTitle( |
|
66 | $title |
||
|
|||
67 | 2 | ); |
|
68 | |||
69 | 2 | if ( !$user instanceof User ) { |
|
70 | return; |
||
71 | } |
||
72 | |||
73 | 2 | foreach ( $user->getRights() as $right ) { |
|
74 | 1 | $semanticData->addPropertyObjectValue( $property, new DIBlob( $right ) ); |
|
75 | 2 | } |
|
76 | 2 | } |
|
77 | |||
79 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: