3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getBatchSize(int $totalRecordsCount) : int { $batchSize = (int) ceil($totalRecordsCount / 5000); $roundDivisor = pow(10, strlen((string) $batchSize) - 1); $batchSize = (int) ceil($batchSize / $roundDivisor) * $roundDivisor; var_dump($batchSize); return max( 10, min(100, $batchSize) ); } var_dump(getBatchSize(212522), '---'); var_dump(getBatchSize(2125223), '---');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vd26s
function name:  (null)
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getbatchsize'
          2        SEND_VAL                                                 212522
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        SEND_VAL                                                 '---'
          6        DO_ICALL                                                 
   22     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'getbatchsize'
          9        SEND_VAL                                                 2125223
         10        DO_FCALL                                      0  $2      
         11        SEND_VAR                                                 $2
         12        SEND_VAL                                                 '---'
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function getbatchsize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vd26s
function name:  getBatchSize
number of ops:  37
compiled vars:  !0 = $totalRecordsCount, !1 = $batchSize, !2 = $roundDivisor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'ceil'
          2        DIV                                              ~3      !0, 5000
          3        SEND_VAL                                                 ~3
          4        DO_ICALL                                         $4      
          5        CAST                                          4  ~5      $4
          6        ASSIGN                                                   !1, ~5
    7     7        INIT_FCALL                                               'pow'
          8        SEND_VAL                                                 10
          9        CAST                                          6  ~7      !1
         10        STRLEN                                           ~8      ~7
         11        SUB                                              ~9      ~8, 1
         12        SEND_VAL                                                 ~9
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !2, $10
    9    15        INIT_FCALL                                               'ceil'
         16        DIV                                              ~12     !1, !2
         17        SEND_VAL                                                 ~12
         18        DO_ICALL                                         $13     
         19        CAST                                          4  ~14     $13
         20        MUL                                              ~15     !2, ~14
         21        ASSIGN                                                   !1, ~15
   11    22        INIT_FCALL                                               'var_dump'
         23        SEND_VAR                                                 !1
         24        DO_ICALL                                                 
   13    25        INIT_FCALL                                               'max'
   14    26        SEND_VAL                                                 10
   15    27        INIT_FCALL                                               'min'
         28        SEND_VAL                                                 100
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $18     
         31        SEND_VAR                                                 $18
         32        DO_ICALL                                         $19     
         33        VERIFY_RETURN_TYPE                                       $19
         34      > RETURN                                                   $19
   17    35*       VERIFY_RETURN_TYPE                                       
         36*     > RETURN                                                   null

End of function getbatchsize

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
276.9 ms | 1403 KiB | 26 Q