3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Prices { private $priceList = array( /* HR EN DE FR IT ES */ /* HR */ '0 100 100 100 100 100', /* EN */ '80 0 120 120 120 120', /* DE */ '80 120 0 120 120 120', /* FR */ '80 120 120 0 120 120', /* IT */ '80 120 120 120 0 120', /* ES */ '80 120 120 120 120 0', ); private $coef = 1; private $languages = array('HR', 'EN', 'DE', 'FR', 'IT', 'ES'); // Must be the same order as in $priceList public function getRate($source, $target) { $this->verifyPriceList(); $sourceKey = array_search($source, $this->priceList); $targetKey = array_search($target, $this->priceList); return intval(explode('\t', $this->priceList[$sourceKey])[$targetKey]); } /* $priceList must not contain spaces */ private function verifyPriceList() { if (strstr(implode('', $this->priceList), ' ') !== FALSE) throw Exception('Price list contains spaces! Location: class.Prices.php'); } } $p = new Prices(); echo $p->getRate('HR', 'EN'); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MOe2r
function name:  (null)
number of ops:  9
compiled vars:  !0 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   NEW                                              $1      'Prices'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   39     3        INIT_METHOD_CALL                                         !0, 'getRate'
          4        SEND_VAL_EX                                              'HR'
          5        SEND_VAL_EX                                              'EN'
          6        DO_FCALL                                      0  $4      
          7        ECHO                                                     $4
   41     8      > RETURN                                                   1

Class Prices:
Function getrate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MOe2r
function name:  getRate
number of ops:  26
compiled vars:  !0 = $source, !1 = $target, !2 = $sourceKey, !3 = $targetKey
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2        INIT_METHOD_CALL                                         'verifyPriceList'
          3        DO_FCALL                                      0          
   22     4        INIT_FCALL                                               'array_search'
          5        SEND_VAR                                                 !0
          6        FETCH_OBJ_R                                      ~5      'priceList'
          7        SEND_VAL                                                 ~5
          8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !2, $6
   23    10        INIT_FCALL                                               'array_search'
         11        SEND_VAR                                                 !1
         12        FETCH_OBJ_R                                      ~8      'priceList'
         13        SEND_VAL                                                 ~8
         14        DO_ICALL                                         $9      
         15        ASSIGN                                                   !3, $9
   24    16        INIT_FCALL                                               'explode'
         17        SEND_VAL                                                 '%5Ct'
         18        FETCH_OBJ_R                                      ~11     'priceList'
         19        FETCH_DIM_R                                      ~12     ~11, !2
         20        SEND_VAL                                                 ~12
         21        DO_ICALL                                         $13     
         22        FETCH_DIM_R                                      ~14     $13, !3
         23        CAST                                          4  ~15     ~14
         24      > RETURN                                                   ~15
   26    25*     > RETURN                                                   null

End of function getrate

Function verifypricelist:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 15
Branch analysis from position: 11
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MOe2r
function name:  verifyPriceList
number of ops:  16
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'strstr'
          1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 ''
          3        FETCH_OBJ_R                                      ~0      'priceList'
          4        SEND_VAL                                                 ~0
          5        DO_ICALL                                         $1      
          6        SEND_VAR                                                 $1
          7        SEND_VAL                                                 '+'
          8        DO_ICALL                                         $2      
          9        TYPE_CHECK                                  1018          $2
         10      > JMPZ                                                     ~3, ->15
   31    11    >   INIT_FCALL_BY_NAME                                       'Exception'
         12        SEND_VAL_EX                                              'Price+list+contains+spaces%21+Location%3A+class.Prices.php'
         13        DO_FCALL                                      0  $4      
         14      > THROW                                         0          $4
   32    15    > > RETURN                                                   null

End of function verifypricelist

End of class Prices.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.37 ms | 1400 KiB | 21 Q