3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Shipping { /** * @return integer The minimum number of boxes needed to hold a given number of items */ public static function minimalNumberOfPackages($items, $availableLargePackages, $availableSmallPackages) { $maxSize = 5; $minSize = 1; if ($items < $maxSize) return $items * $minSize; if (($items - ($maxSize * $availableLargePackages + $availableSmallPackages)) > 0) return -1; $itemsNotHoldByMax = $items / 5; var_dump($itemsNotHoldByMax); if ($itemsNotHoldByMax > $items) $itemsNotHoldByMax = $availableLargePackages; return $itemsNotHoldByMax + ($items - $maxSize * $itemsNotHoldByMax); } } echo Shipping::minimalNumberOfPackages(16, 2, 10);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Qf2W8
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   INIT_STATIC_METHOD_CALL                                      'Shipping', 'minimalNumberOfPackages'
          1        SEND_VAL                                                     16
          2        SEND_VAL                                                     2
          3        SEND_VAL                                                     10
          4        DO_FCALL                                          0  $0      
          5        ECHO                                                         $0
          6      > RETURN                                                       1

Class Shipping:
Function minimalnumberofpackages:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 9
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/Qf2W8
function name:  minimalNumberOfPackages
number of ops:  28
compiled vars:  !0 = $items, !1 = $availableLargePackages, !2 = $availableSmallPackages, !3 = $maxSize, !4 = $minSize, !5 = $itemsNotHoldByMax
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        RECV                                                 !2      
   10     3        ASSIGN                                                       !3, 5
   11     4        ASSIGN                                                       !4, 1
   12     5        IS_SMALLER                                                   !0, !3
          6      > JMPZ                                                         ~8, ->9
   13     7    >   MUL                                                  ~9      !0, !4
          8      > RETURN                                                       ~9
   15     9    >   MUL                                                  ~10     !3, !1
         10        ADD                                                  ~11     ~10, !2
         11        SUB                                                  ~12     !0, ~11
         12        IS_SMALLER                                                   0, ~12
         13      > JMPZ                                                         ~13, ->15
   16    14    > > RETURN                                                       -1
   18    15    >   DIV                                                  ~14     !0, 5
         16        ASSIGN                                                       !5, ~14
   19    17        INIT_FCALL                                                   'var_dump'
         18        SEND_VAR                                                     !5
         19        DO_ICALL                                                     
   20    20        IS_SMALLER                                                   !0, !5
         21      > JMPZ                                                         ~17, ->23
   21    22    >   ASSIGN                                                       !5, !1
   23    23    >   MUL                                                  ~19     !3, !5
         24        SUB                                                  ~20     !0, ~19
         25        ADD                                                  ~21     !5, ~20
         26      > RETURN                                                       ~21
   24    27*     > RETURN                                                       null

End of function minimalnumberofpackages

End of class Shipping.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
215.4 ms | 2606 KiB | 14 Q