| Conditions | 6 | 
| Paths | 5 | 
| Total Lines | 30 | 
| Code Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 17 | 
| CRAP Score | 6.042 | 
| Changes | 0 | ||
| 1 | <?php | ||
| 57 | 6 | 	public function addAnnotation( DIProperty $property, SemanticData $semanticData ) { | |
| 58 | |||
| 59 | 6 | $title = $semanticData->getSubject()->getTitle(); | |
| 60 | |||
| 61 | 6 | 		if ( !$title->inNamespace( NS_USER ) ) { | |
| 62 | return; | ||
| 63 | } | ||
| 64 | |||
| 65 | 6 | $user = $this->appFactory->newUserFromTitle( | |
| 66 | $title | ||
|  | |||
| 67 | 6 | ); | |
| 68 | |||
| 69 | 6 | 		if ( !$user instanceof User || ( $block = $user->getBlock() ) === null ) { | |
| 70 | return; | ||
| 71 | } | ||
| 72 | |||
| 73 | $actions = [ | ||
| 74 | 6 | 'edit', | |
| 75 | 6 | 'createaccount', | |
| 76 | 6 | 'sendemail', | |
| 77 | 6 | 'editownusertalk', | |
| 78 | 'read' | ||
| 79 | 6 | ]; | |
| 80 | |||
| 81 | 6 | 		foreach ( $actions as $action ) { | |
| 82 | 6 | 			if ( $block->prevents( $action ) ) { | |
| 83 | 5 | $semanticData->addPropertyObjectValue( $property, new DIBlob( $action ) ); | |
| 84 | 5 | } | |
| 85 | 6 | } | |
| 86 | 6 | } | |
| 87 | |||
| 89 | 
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: