Conditions | 6 |
Paths | 5 |
Total Lines | 19 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 6.0163 |
Changes | 0 |
1 | <?php |
||
57 | 3 | public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { |
|
58 | |||
59 | 3 | $title = $semanticData->getSubject()->getTitle(); |
|
60 | |||
61 | 3 | if ( !$title->inNamespace( NS_USER ) ) { |
|
62 | return; |
||
63 | } |
||
64 | |||
65 | 3 | $user = $this->appFactory->newUserFromTitle( $title ); |
|
|
|||
66 | 3 | $dataItem = null; |
|
67 | |||
68 | 3 | if ( $user instanceof User && ( $count = $user->getEditCount() ) && is_int( $count ) ) { |
|
69 | 1 | $dataItem = new DINumber( $count ); |
|
70 | 1 | } |
|
71 | |||
72 | 3 | if ( $dataItem instanceof DataItem ) { |
|
73 | 1 | $semanticData->addPropertyObjectValue( $property, $dataItem ); |
|
74 | 1 | } |
|
75 | 3 | } |
|
76 | |||
78 |
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: