| Conditions | 8 |
| Paths | 17 |
| Total Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 19 |
| CRAP Score | 8.0079 |
| Changes | 0 | ||
| 1 | <?php |
||
| 24 | 4 | public function parseDate( TimeValue $dataValue, $isEnd = false ) { |
|
| 25 | 4 | $year = $dataValue->getYear(); |
|
| 26 | |||
| 27 | // ISO range is limited to four digits |
||
| 28 | 4 | if ( ( $year > 9999 ) || ( $year < -9998 ) ) { |
|
| 29 | return ''; |
||
| 30 | } |
||
| 31 | |||
| 32 | 4 | $year = number_format( $year, 0, '.', '' ); |
|
| 33 | 4 | $time = str_replace( ':', '', $dataValue->getTimeString( false ) ); |
|
|
|
|||
| 34 | |||
| 35 | // increment by one day, compute date to cover leap years etc. |
||
| 36 | 4 | if ( ( $time == false ) && ( $isEnd ) ) { |
|
| 37 | 1 | $dataValue = DataValueFactory::getInstance()->newDataValueByType( |
|
| 38 | 1 | '_dat', |
|
| 39 | 1 | $dataValue->getWikiValue() . 'T00:00:00-24:00' |
|
| 40 | ); |
||
| 41 | } |
||
| 42 | |||
| 43 | 4 | $month = $dataValue->getMonth(); |
|
| 44 | |||
| 45 | 4 | if ( strlen( $month ) == 1 ) { |
|
| 46 | 3 | $month = '0' . $month; |
|
| 47 | } |
||
| 48 | |||
| 49 | 4 | $day = $dataValue->getDay(); |
|
| 50 | |||
| 51 | 4 | if ( strlen( $day ) == 1 ) { |
|
| 52 | 3 | $day = '0' . $day; |
|
| 53 | } |
||
| 54 | |||
| 55 | 4 | $result = $year . $month . $day; |
|
| 56 | |||
| 57 | 4 | if ( $time != false ) { |
|
| 58 | 3 | $result .= "T$time"; |
|
| 59 | } |
||
| 60 | |||
| 61 | 4 | return $result; |
|
| 62 | } |
||
| 63 | |||
| 65 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: