| Conditions | 5 |
| Paths | 8 |
| Total Lines | 29 |
| Code Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 5.2259 |
| Changes | 0 | ||
| 1 | <?php |
||
| 61 | 2 | public function addAnnotation( |
|
| 62 | DIProperty $property, SemanticData $semanticData |
||
| 63 | ) { |
||
| 64 | 2 | if ( $this->approvedDate === null && class_exists( 'ApprovedRevs' ) ) { |
|
| 65 | $logReader = $this->appFactory->newDatabaseLogReader( |
||
| 66 | $semanticData->getSubject()->getTitle(), 'approval' |
||
|
|
|||
| 67 | ); |
||
| 68 | $this->approvedDate = $logReader->getDate(); |
||
| 69 | } |
||
| 70 | |||
| 71 | 2 | $dataItem = null; |
|
| 72 | 2 | if ( $this->approvedDate ) { |
|
| 73 | 1 | $date = $this->approvedDate; |
|
| 74 | 1 | $dataItem = new DITime( |
|
| 75 | 1 | DITime::CM_GREGORIAN, |
|
| 76 | 1 | $date->format( 'Y' ), |
|
| 77 | 1 | $date->format( 'm' ), |
|
| 78 | 1 | $date->format( 'd' ), |
|
| 79 | 1 | $date->format( 'H' ), |
|
| 80 | 1 | $date->format( 'i' ) |
|
| 81 | 1 | ); |
|
| 82 | 1 | } |
|
| 83 | |||
| 84 | 2 | if ( $dataItem instanceof DataItem ) { |
|
| 85 | 1 | $semanticData->addPropertyObjectValue( $property, $dataItem ); |
|
| 86 | 1 | } else { |
|
| 87 | 1 | $semanticData->removeProperty( $property ); |
|
| 88 | } |
||
| 89 | 2 | } |
|
| 90 | } |
||
| 91 |
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: