3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRoundedCutoff ($t) { list($hour, $min, $sec) = explode(':', $t); $rmin = $time[1] % 15; $dt = new DateTime( $t ); if ( $sec > 30 ) { $dt->add(new DateInterval('PT'.(60-$sec).'M')); } else { $dt->sub(new DateInterval('PT'.$sec.'M')); } 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:52:00', '10:52:59', '10:53:00', '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:59: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/XH9h1
function name:  (null)
number of ops:  14
compiled vars:  !0 = $times, !1 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   38     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   39     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                                                 
   38    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   40    13      > RETURN                                                   1

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

End of function getroundedcutoff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.19 ms | 1407 KiB | 18 Q