| Conditions | 7 |
| Paths | 10 |
| Total Lines | 19 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 23 | public static function isMonotonic2(array $arr): bool |
||
| 24 | { |
||
| 25 | if (empty($arr)) { |
||
| 26 | return false; |
||
| 27 | } |
||
| 28 | $inc = $dec = true; |
||
| 29 | for ($i = 0, $n = count($arr) - 1; $i < $n; $i++) { |
||
| 30 | if ($arr[$i] > $arr[$i + 1]) { |
||
| 31 | $inc = false; |
||
| 32 | } |
||
| 33 | if ($arr[$i] < $arr[$i + 1]) { |
||
| 34 | $dec = false; |
||
| 35 | } |
||
| 36 | if ($inc === false && $dec === false) { |
||
| 37 | return false; |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 41 | return true; |
||
| 42 | } |
||
| 44 |