| Conditions | 4 |
| Paths | 5 |
| Total Lines | 23 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 4 |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | 24 | protected function dateFormat($string) |
|
| 23 | { |
||
| 24 | 24 | $zone = 'America/Sao_Paulo'; |
|
| 25 | |||
| 26 | 24 | if (intval($string) === $string) { |
|
| 27 | 2 | $df = date_default_timezone_get(); |
|
| 28 | 2 | if ($df !== $zone) { |
|
| 29 | 2 | date_default_timezone_set($zone); |
|
| 30 | } |
||
| 31 | 2 | $date = date('c', $string / 1000); |
|
| 32 | |||
| 33 | 2 | if ($df !== $zone) { |
|
| 34 | 2 | date_default_timezone_set($df); |
|
| 35 | } |
||
| 36 | |||
| 37 | 2 | return $date; |
|
| 38 | } |
||
| 39 | |||
| 40 | 22 | $timezone = new DateTimeZone($zone); |
|
| 41 | 22 | $datetime = new DateTime($string, $timezone); |
|
| 42 | |||
| 43 | 22 | return $datetime->format('c'); |
|
| 44 | } |
||
| 45 | |||
| 57 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idableprovides a methodequalsIdthat in turn relies on the methodgetId(). If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()as an abstract method to the trait will make sure it is available.