3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRoundedCutoff ($cutoff) { $dt = new DateTime( $cutoff ); $sec = intval($dt->format('s')); $min = intval($dt->format('i')); $rmin = $min % 15; if ( $sec > 30 ) { $dt->add(new DateInterval('PT'.(60-$sec).'S')); } else { $dt->sub(new DateInterval('PT'.$sec.'S')); } if ( $rmin > 7 ) { $dt->add(new DateInterval('PT'.(15-$rmin).'M')); } else { $dt->sub(new DateInterval('PT'.$rmin.'M')); } return $dt->format('H:i:s'); } $times = array( '10:50:00', '10:50:14', '10:50:59', '10:50:45', '01:12:00', '01:05:00', '01:58:00', '01:58:59', '01:01:00', ); foreach ($times as $time) { var_dump($time.' -> '.getRoundedCutoff($time)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/TeFVc
function name:  (null)
number of ops:  14
compiled vars:  !0 = $times, !1 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   35     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   36     3    >   INIT_FCALL                                               'var_dump'
          4        CONCAT                                           ~4      !1, '+-%3E+'
          5        INIT_FCALL                                               'getroundedcutoff'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $5      
          8        CONCAT                                           ~6      ~4, $5
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   35    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   37    13      > RETURN                                                   1

Function getroundedcutoff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 49
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 57
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 49
Branch analysis from position: 39
Branch analysis from position: 49
filename:       /in/TeFVc
function name:  getRoundedCutoff
number of ops:  62
compiled vars:  !0 = $cutoff, !1 = $dt, !2 = $sec, !3 = $min, !4 = $rmin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $5      'DateTime'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $5
    4     5        INIT_METHOD_CALL                                         !1, 'format'
          6        SEND_VAL_EX                                              's'
          7        DO_FCALL                                      0  $8      
          8        CAST                                          4  ~9      $8
          9        ASSIGN                                                   !2, ~9
    5    10        INIT_METHOD_CALL                                         !1, 'format'
         11        SEND_VAL_EX                                              'i'
         12        DO_FCALL                                      0  $11     
         13        CAST                                          4  ~12     $11
         14        ASSIGN                                                   !3, ~12
    6    15        MOD                                              ~14     !3, 15
         16        ASSIGN                                                   !4, ~14
    8    17        IS_SMALLER                                               30, !2
         18      > JMPZ                                                     ~16, ->29
    9    19    >   INIT_METHOD_CALL                                         !1, 'add'
         20        NEW                                              $17     'DateInterval'
         21        SUB                                              ~18     60, !2
         22        CONCAT                                           ~19     'PT', ~18
         23        CONCAT                                           ~20     ~19, 'S'
         24        SEND_VAL_EX                                              ~20
         25        DO_FCALL                                      0          
         26        SEND_VAR_NO_REF_EX                                       $17
         27        DO_FCALL                                      0          
         28      > JMP                                                      ->37
   11    29    >   INIT_METHOD_CALL                                         !1, 'sub'
         30        NEW                                              $23     'DateInterval'
         31        CONCAT                                           ~24     'PT', !2
         32        CONCAT                                           ~25     ~24, 'S'
         33        SEND_VAL_EX                                              ~25
         34        DO_FCALL                                      0          
         35        SEND_VAR_NO_REF_EX                                       $23
         36        DO_FCALL                                      0          
   14    37    >   IS_SMALLER                                               7, !4
         38      > JMPZ                                                     ~28, ->49
   15    39    >   INIT_METHOD_CALL                                         !1, 'add'
         40        NEW                                              $29     'DateInterval'
         41        SUB                                              ~30     15, !4
         42        CONCAT                                           ~31     'PT', ~30
         43        CONCAT                                           ~32     ~31, 'M'
         44        SEND_VAL_EX                                              ~32
         45        DO_FCALL                                      0          
         46        SEND_VAR_NO_REF_EX                                       $29
         47        DO_FCALL                                      0          
         48      > JMP                                                      ->57
   17    49    >   INIT_METHOD_CALL                                         !1, 'sub'
         50        NEW                                              $35     'DateInterval'
         51        CONCAT                                           ~36     'PT', !4
         52        CONCAT                                           ~37     ~36, 'M'
         53        SEND_VAL_EX                                              ~37
         54        DO_FCALL                                      0          
         55        SEND_VAR_NO_REF_EX                                       $35
         56        DO_FCALL                                      0          
   20    57    >   INIT_METHOD_CALL                                         !1, 'format'
         58        SEND_VAL_EX                                              'H%3Ai%3As'
         59        DO_FCALL                                      0  $40     
         60      > RETURN                                                   $40
   21    61*     > RETURN                                                   null

End of function getroundedcutoff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.98 ms | 1403 KiB | 16 Q