3v4l.org

run code in 300+ PHP versions simultaneously
<?php echo mtx_api_minutes_to_hours_format(0), "\n"; echo mtx_api_minutes_to_hours_format(1), "\n"; echo mtx_api_minutes_to_hours_format(10), "\n"; echo mtx_api_minutes_to_hours_format(60), "\n"; echo mtx_api_minutes_to_hours_format(61), "\n"; echo mtx_api_minutes_to_hours_format(62), "\n"; echo mtx_api_minutes_to_hours_format(74), "\n"; echo mtx_api_minutes_to_hours_format(120), "\n"; echo mtx_api_minutes_to_hours_format(121), "\n"; function mtx_api_minutes_to_hours_format(int $minutes): string { if ($minutes < 60) { return mtx_api_format_plural($minutes, '@count minute', '@count minutes'); } if (!$remaining_minutes = $minutes % 60) { return mtx_api_format_plural(intdiv($minutes, 60), '@count hour', '@count hours'); } return format_string('!hours !minutes', [ '!hours' => mtx_api_format_plural(intdiv($minutes, 60), '@count hour', '@count hours'), '!minutes' => mtx_api_format_plural($remaining_minutes, '@count minute', '@count minutes'), ]); } function mtx_api_format_plural($count, $singular, $plural) { return $count == 1 ? "$count $singular" : "$count $plural"; } function format_string($string, array $args = array()) { return strtr($string, $args); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GfMvO
function name:  (null)
number of ops:  46
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
          1        SEND_VAL_EX                                              0
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4        ECHO                                                     '%0A'
    4     5        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
          6        SEND_VAL_EX                                              1
          7        DO_FCALL                                      0  $1      
          8        ECHO                                                     $1
          9        ECHO                                                     '%0A'
    5    10        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         11        SEND_VAL_EX                                              10
         12        DO_FCALL                                      0  $2      
         13        ECHO                                                     $2
         14        ECHO                                                     '%0A'
    6    15        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         16        SEND_VAL_EX                                              60
         17        DO_FCALL                                      0  $3      
         18        ECHO                                                     $3
         19        ECHO                                                     '%0A'
    7    20        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         21        SEND_VAL_EX                                              61
         22        DO_FCALL                                      0  $4      
         23        ECHO                                                     $4
         24        ECHO                                                     '%0A'
    8    25        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         26        SEND_VAL_EX                                              62
         27        DO_FCALL                                      0  $5      
         28        ECHO                                                     $5
         29        ECHO                                                     '%0A'
    9    30        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         31        SEND_VAL_EX                                              74
         32        DO_FCALL                                      0  $6      
         33        ECHO                                                     $6
         34        ECHO                                                     '%0A'
   10    35        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         36        SEND_VAL_EX                                              120
         37        DO_FCALL                                      0  $7      
         38        ECHO                                                     $7
         39        ECHO                                                     '%0A'
   11    40        INIT_FCALL_BY_NAME                                       'mtx_api_minutes_to_hours_format'
         41        SEND_VAL_EX                                              121
         42        DO_FCALL                                      0  $8      
         43        ECHO                                                     $8
         44        ECHO                                                     '%0A'
   33    45      > RETURN                                                   1

Function mtx_api_minutes_to_hours_format:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 10
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GfMvO
function name:  mtx_api_minutes_to_hours_format
number of ops:  49
compiled vars:  !0 = $minutes, !1 = $remaining_minutes
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        IS_SMALLER                                               !0, 60
          2      > JMPZ                                                     ~2, ->10
   15     3    >   INIT_FCALL_BY_NAME                                       'mtx_api_format_plural'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              '%40count+minute'
          6        SEND_VAL_EX                                              '%40count+minutes'
          7        DO_FCALL                                      0  $3      
          8        VERIFY_RETURN_TYPE                                       $3
          9      > RETURN                                                   $3
   18    10    >   MOD                                              ~4      !0, 60
         11        ASSIGN                                           ~5      !1, ~4
         12        BOOL_NOT                                         ~6      ~5
         13      > JMPZ                                                     ~6, ->25
   19    14    >   INIT_FCALL_BY_NAME                                       'mtx_api_format_plural'
         15        INIT_FCALL                                               'intdiv'
         16        SEND_VAR                                                 !0
         17        SEND_VAL                                                 60
         18        DO_ICALL                                         $7      
         19        SEND_VAR_NO_REF_EX                                       $7
         20        SEND_VAL_EX                                              '%40count+hour'
         21        SEND_VAL_EX                                              '%40count+hours'
         22        DO_FCALL                                      0  $8      
         23        VERIFY_RETURN_TYPE                                       $8
         24      > RETURN                                                   $8
   22    25    >   INIT_FCALL_BY_NAME                                       'format_string'
         26        SEND_VAL_EX                                              '%21hours+%21minutes'
   23    27        INIT_FCALL_BY_NAME                                       'mtx_api_format_plural'
         28        INIT_FCALL                                               'intdiv'
         29        SEND_VAR                                                 !0
         30        SEND_VAL                                                 60
         31        DO_ICALL                                         $9      
         32        SEND_VAR_NO_REF_EX                                       $9
         33        SEND_VAL_EX                                              '%40count+hour'
         34        SEND_VAL_EX                                              '%40count+hours'
         35        DO_FCALL                                      0  $10     
         36        INIT_ARRAY                                       ~11     $10, '%21hours'
   24    37        INIT_FCALL_BY_NAME                                       'mtx_api_format_plural'
         38        SEND_VAR_EX                                              !1
         39        SEND_VAL_EX                                              '%40count+minute'
         40        SEND_VAL_EX                                              '%40count+minutes'
         41        DO_FCALL                                      0  $12     
         42        ADD_ARRAY_ELEMENT                                ~11     $12, '%21minutes'
         43        SEND_VAL_EX                                              ~11
   22    44        DO_FCALL                                      0  $13     
   24    45        VERIFY_RETURN_TYPE                                       $13
         46      > RETURN                                                   $13
   26    47*       VERIFY_RETURN_TYPE                                       
         48*     > RETURN                                                   null

End of function mtx_api_minutes_to_hours_format

Function mtx_api_format_plural:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GfMvO
function name:  mtx_api_format_plural
number of ops:  16
compiled vars:  !0 = $count, !1 = $singular, !2 = $plural
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   29     3        IS_EQUAL                                                 !0, 1
          4      > JMPZ                                                     ~3, ->10
          5    >   ROPE_INIT                                     3  ~5      !0
          6        ROPE_ADD                                      1  ~5      ~5, '+'
          7        ROPE_END                                      2  ~4      ~5, !1
          8        QM_ASSIGN                                        ~7      ~4
          9      > JMP                                                      ->14
         10    >   ROPE_INIT                                     3  ~9      !0
         11        ROPE_ADD                                      1  ~9      ~9, '+'
         12        ROPE_END                                      2  ~8      ~9, !2
         13        QM_ASSIGN                                        ~7      ~8
         14    > > RETURN                                                   ~7
   30    15*     > RETURN                                                   null

End of function mtx_api_format_plural

Function format_string:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GfMvO
function name:  format_string
number of ops:  8
compiled vars:  !0 = $string, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <array>
   32     2        INIT_FCALL                                               'strtr'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $2      
          6      > RETURN                                                   $2
   33     7*     > RETURN                                                   null

End of function format_string

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.33 ms | 1024 KiB | 15 Q