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