| Conditions | 4 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 52 | public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { |
||
| 53 | |||
| 54 | $title = $semanticData->getSubject()->getTitle(); |
||
| 55 | |||
| 56 | if ( !$title->inNamespace( NS_USER ) ) { |
||
| 57 | return; |
||
| 58 | } |
||
| 59 | |||
| 60 | $user = $this->appFactory->newUserFromTitle( $title ); |
||
|
|
|||
| 61 | $dataItem = null; |
||
| 62 | |||
| 63 | if ( $user instanceof User ) { |
||
| 64 | $dataItem = new DINumber( $user->getEditCount() ); |
||
| 65 | } |
||
| 66 | |||
| 67 | if ( $dataItem instanceof DataItem ) { |
||
| 68 | $semanticData->addPropertyObjectValue( $property, $dataItem ); |
||
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 73 |
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: