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; return max( 10, min(100, $batchSize) ); } var_dump(getBatchSize(5), '---'); var_dump(getBatchSize(17), '---'); var_dump(getBatchSize(173), '---'); 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/kFuRH
function name:  (null)
number of ops:  36
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getbatchsize'
          2        SEND_VAL                                                 5
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        SEND_VAL                                                 '---'
          6        DO_ICALL                                                 
   18     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'getbatchsize'
          9        SEND_VAL                                                 17
         10        DO_FCALL                                      0  $2      
         11        SEND_VAR                                                 $2
         12        SEND_VAL                                                 '---'
         13        DO_ICALL                                                 
   19    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'getbatchsize'
         16        SEND_VAL                                                 173
         17        DO_FCALL                                      0  $4      
         18        SEND_VAR                                                 $4
         19        SEND_VAL                                                 '---'
         20        DO_ICALL                                                 
   20    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'getbatchsize'
         23        SEND_VAL                                                 212522
         24        DO_FCALL                                      0  $6      
         25        SEND_VAR                                                 $6
         26        SEND_VAL                                                 '---'
         27        DO_ICALL                                                 
   21    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'getbatchsize'
         30        SEND_VAL                                                 2125223
         31        DO_FCALL                                      0  $8      
         32        SEND_VAR                                                 $8
         33        SEND_VAL                                                 '---'
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Function getbatchsize:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/kFuRH
function name:  getBatchSize
number of ops:  34
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                                               'max'
   12    23        SEND_VAL                                                 10
   13    24        INIT_FCALL                                               'min'
         25        SEND_VAL                                                 100
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $17     
         28        SEND_VAR                                                 $17
         29        DO_ICALL                                         $18     
         30        VERIFY_RETURN_TYPE                                       $18
         31      > RETURN                                                   $18
   15    32*       VERIFY_RETURN_TYPE                                       
         33*     > RETURN                                                   null

End of function getbatchsize

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.47 ms | 1407 KiB | 28 Q