3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Katoga\Allyourbase; /** * @author Katoga <katoga.cz@hotmail.com> */ class Base32 implements Transcoder { /** * A-Z, 2-7 * New RFC that obsoleted RFC3548, uses the same alphabet. * * @var int */ const RFC4648 = 1; /** * 0-9, A-V * "Extended hex" or "base32hex" * * @var int */ const RFC2938 = 2; /** * 0-9, A-Z without I, L, O, U * * @link http://www.crockford.com/wrmg/base32.html * @var int */ const CROCKFORD = 3; /** * @var string */ const PAD_CHAR = '='; const ENCODE = 1; const DECODE = 1; /** * @var array */ protected $alphabet = [ self::RFC4648 => [ self::ENCODE => [], self::DECODE => [], ], self::RFC2938 => [ self::ENCODE => [], self::DECODE => [], ], self::CROCKFORD => [ self::ENCODE => [], self::DECODE => [], ], ]; /** * @param string $input binary string * @param int $type alphabet type * @return string ascii string */ public function encode($input, $type = self::RFC4648) { $output = ''; if ($input !== '') { $alphabet = $this->getAlphabet($type); // create binary represantation of input string $binStr = ''; foreach (str_split($input) as $char) { // append 8 bits of source string // padding zeros needed for chars with ASCII position < 64 (up to '?') // or portions of splitted multibyte chars $binStr .= str_pad(decbin(ord($char)), 8, '0', STR_PAD_LEFT); } // pad binary string, its length has to be divisible by 5 $binStr = $this->pad($binStr, 5, '0'); // split binary string to 5bit chunks $binArr = explode(' ', trim(chunk_split($binStr, 5, ' '))); // encode foreach ($binArr as $binChar) { $output .= $alphabet[bindec($binChar)]; } // pad output, its length has to be divisible by 8 $output = $this->pad($output, 8, self::PAD_CHAR); } return $output; } /** * @param string $input ascii string * @param int $type alphabet type * @return string binary string * @throws DecodeFailedException */ public function decode($input, $type = self::RFC4648) { $output = ''; if ($input !== '') { $alphabet = $this->getDecodingAlphabet($type); // convert input to uppercase and remove trailing padding chars $input = rtrim(strtoupper($input), self::PAD_CHAR); $binStr = ''; foreach (str_split($input) as $ch) { if (!isset($alphabet[$ch])) { throw new DecodeFailedException(); } // append 5bit binary representation of encoded char $binStr .= str_pad((decbin($alphabet[$ch])), 5, '0', STR_PAD_LEFT); } // trim zeros from tight side of binary string, its length has to be divisible by 8 $binStr = $this->trim($binStr, 8, '0'); $binArr = explode(' ', trim(chunk_split($binStr, 8, ' '))); foreach ($binArr as $bin) { $output .= chr(bindec($bin)); } } return $output; } /** * Pads $string on right side with $char to length divisible by $factor * * @param string $string * @param int $factor * @param string $char */ protected function pad($string, $factor, $char) { $output = $string; $length = strlen($string); $modulo = $length % $factor; if ($modulo != 0) { $outputPaddedLength = $length + ($factor - $modulo); $output = str_pad($output, $outputPaddedLength, $char, STR_PAD_RIGHT); } return $output; } /** * Trims $char from right side of $string to length divisible by $factor * * @param string $string * @param int $factor * @param string $char */ protected function trim($string, $factor, $char) { $output = $string; $length = strlen($string); $modulo = $length % $factor; if ($modulo != 0) { $outputTrimmedLength = $length - $modulo; $output = substr($output, 0, $outputTrimmedLength); } return $output; } /** * @param int $type * @return array */ protected function getEncodingAlphabet($type) { return $this->alphabet[$type][self::ENCODE]; } /** * @param int $type * @return array */ protected function getDecodingAlphabet($type) { return $this->getAlphabet($type, self::DECODE); } /** * @param int $type * @param int $mode * @return array * @throws \InvalidArgumentException */ protected function getAlphabet($type, $mode) { if (!isset($this->alphabet[$type])) { throw new InvalidArgumentException(sprintf('Wrong alphabet requested: "%s"!', $type)); } if (!isset($this->alphabet[$type][$mode])) { throw new InvalidArgumentException(sprintf('Wrong mode requested: "%s"!', $mode)); } if (empty($this->alphabet[$type][$mode])) { // generate the requested alphabet switch ($type) { case self::RFC4648: $alphabet = array_merge( range('A', 'Z'), ['2', '3', '4', '5', '6', '7'] ); $this->alphabet[$type][self::ENCODE] = $alphabet; $this->alphabet[$type][self::DECODE] = array_flip($alphabet); break; case self::RFC2938: $alphabet = array_merge( ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], range('A', 'V') ); $this->alphabet[$type][self::ENCODE] = $alphabet; $this->alphabet[$type][self::DECODE] = array_flip($alphabet); break; case self::CROCKFORD: $alphabet = array_merge( ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], array_diff( range('A', 'Z'), ['I', 'L', 'O', 'U'] ) ); $this->alphabet[$type][self::ENCODE] = $alphabet; $decodeCrockford = array_merge( array_flip($alphabet), [ 'I' => 1, 'L' => 1, 'O' => 0 ] ); $lowercase = range('a', 'z'); unset($lowercase[20]); foreach ($lowercase as $ch) { $decodeCrockford[$ch] = $decodeCrockford[strtoupper($ch)]; } $this->alphabet[$type][self::DECODE] = $decodeCrockford; break; } } return $this->alphabet[$type][$mode]; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cn051
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   DECLARE_CLASS                                            'katoga%5Callyourbase%5Cbase32'
  264     1      > RETURN                                                   1

Class Katoga\Allyourbase\Base32:
Function encode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 66
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 30
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 51, Position 2 = 58
Branch analysis from position: 51
2 jumps found. (Code = 78) Position 1 = 52, Position 2 = 58
Branch analysis from position: 52
1 jumps found. (Code = 42) Position 1 = 51
Branch analysis from position: 51
Branch analysis from position: 58
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
Branch analysis from position: 30
Branch analysis from position: 66
filename:       /in/Cn051
function name:  encode
number of ops:  68
compiled vars:  !0 = $input, !1 = $type, !2 = $output, !3 = $alphabet, !4 = $binStr, !5 = $char, !6 = $binArr, !7 = $binChar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   66     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
   68     2        ASSIGN                                                   !2, ''
   70     3        IS_NOT_IDENTICAL                                         !0, ''
          4      > JMPZ                                                     ~9, ->66
   71     5    >   INIT_METHOD_CALL                                         'getAlphabet'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !3, $10
   73     9        ASSIGN                                                   !4, ''
   74    10        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstr_split'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $13     
         13      > FE_RESET_R                                       $14     $13, ->30
         14    > > FE_FETCH_R                                               $14, !5, ->30
   78    15    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstr_pad'
         16        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cdecbin'
         17        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cord'
         18        SEND_VAR_EX                                              !5
         19        DO_FCALL                                      0  $15     
         20        SEND_VAR_NO_REF_EX                                       $15
         21        DO_FCALL                                      0  $16     
         22        SEND_VAR_NO_REF_EX                                       $16
         23        SEND_VAL_EX                                              8
         24        SEND_VAL_EX                                              '0'
         25        FETCH_CONSTANT                                   ~17     'Katoga%5CAllyourbase%5CSTR_PAD_LEFT'
         26        SEND_VAL_EX                                              ~17
         27        DO_FCALL                                      0  $18     
         28        ASSIGN_OP                                     8          !4, $18
   74    29      > JMP                                                      ->14
         30    >   FE_FREE                                                  $14
   81    31        INIT_METHOD_CALL                                         'pad'
         32        SEND_VAR_EX                                              !4
         33        SEND_VAL_EX                                              5
         34        SEND_VAL_EX                                              '0'
         35        DO_FCALL                                      0  $20     
         36        ASSIGN                                                   !4, $20
   84    37        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cexplode'
         38        SEND_VAL_EX                                              '+'
         39        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Ctrim'
         40        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cchunk_split'
         41        SEND_VAR_EX                                              !4
         42        SEND_VAL_EX                                              5
         43        SEND_VAL_EX                                              '+'
         44        DO_FCALL                                      0  $22     
         45        SEND_VAR_NO_REF_EX                                       $22
         46        DO_FCALL                                      0  $23     
         47        SEND_VAR_NO_REF_EX                                       $23
         48        DO_FCALL                                      0  $24     
         49        ASSIGN                                                   !6, $24
   87    50      > FE_RESET_R                                       $26     !6, ->58
         51    > > FE_FETCH_R                                               $26, !7, ->58
   88    52    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cbindec'
         53        SEND_VAR_EX                                              !7
         54        DO_FCALL                                      0  $27     
         55        FETCH_DIM_R                                      ~28     !3, $27
         56        ASSIGN_OP                                     8          !2, ~28
   87    57      > JMP                                                      ->51
         58    >   FE_FREE                                                  $26
   92    59        INIT_METHOD_CALL                                         'pad'
         60        SEND_VAR_EX                                              !2
         61        SEND_VAL_EX                                              8
         62        FETCH_CLASS_CONSTANT                             ~30     'PAD_CHAR'
         63        SEND_VAL_EX                                              ~30
         64        DO_FCALL                                      0  $31     
         65        ASSIGN                                                   !2, $31
   95    66    > > RETURN                                                   !2
   96    67*     > RETURN                                                   null

End of function encode

Function decode:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 75
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 44
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 44
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 44
2 jumps found. (Code = 77) Position 1 = 65, Position 2 = 74
Branch analysis from position: 65
2 jumps found. (Code = 78) Position 1 = 66, Position 2 = 74
Branch analysis from position: 66
1 jumps found. (Code = 42) Position 1 = 65
Branch analysis from position: 65
Branch analysis from position: 74
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 74
Branch analysis from position: 44
Branch analysis from position: 75
filename:       /in/Cn051
function name:  decode
number of ops:  77
compiled vars:  !0 = $input, !1 = $type, !2 = $output, !3 = $alphabet, !4 = $binStr, !5 = $ch, !6 = $binArr, !7 = $bin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  104     0  E >   RECV                                             !0      
          1        RECV_INIT                                        !1      <const ast>
  106     2        ASSIGN                                                   !2, ''
  108     3        IS_NOT_IDENTICAL                                         !0, ''
          4      > JMPZ                                                     ~9, ->75
  109     5    >   INIT_METHOD_CALL                                         'getDecodingAlphabet'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0  $10     
          8        ASSIGN                                                   !3, $10
  112     9        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Crtrim'
         10        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstrtoupper'
         11        SEND_VAR_EX                                              !0
         12        DO_FCALL                                      0  $12     
         13        SEND_VAR_NO_REF_EX                                       $12
         14        FETCH_CLASS_CONSTANT                             ~13     'PAD_CHAR'
         15        SEND_VAL_EX                                              ~13
         16        DO_FCALL                                      0  $14     
         17        ASSIGN                                                   !0, $14
  114    18        ASSIGN                                                   !4, ''
  115    19        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstr_split'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0  $17     
         22      > FE_RESET_R                                       $18     $17, ->44
         23    > > FE_FETCH_R                                               $18, !5, ->44
  116    24    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !3, !5
         25        BOOL_NOT                                         ~20     ~19
         26      > JMPZ                                                     ~20, ->30
  117    27    >   NEW                                              $21     'Katoga%5CAllyourbase%5CDecodeFailedException'
         28        DO_FCALL                                      0          
         29      > THROW                                         0          $21
  121    30    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstr_pad'
         31        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cdecbin'
         32        CHECK_FUNC_ARG                                           
         33        FETCH_DIM_FUNC_ARG                               $23     !3, !5
         34        SEND_FUNC_ARG                                            $23
         35        DO_FCALL                                      0  $24     
         36        SEND_VAR_NO_REF_EX                                       $24
         37        SEND_VAL_EX                                              5
         38        SEND_VAL_EX                                              '0'
         39        FETCH_CONSTANT                                   ~25     'Katoga%5CAllyourbase%5CSTR_PAD_LEFT'
         40        SEND_VAL_EX                                              ~25
         41        DO_FCALL                                      0  $26     
         42        ASSIGN_OP                                     8          !4, $26
  115    43      > JMP                                                      ->23
         44    >   FE_FREE                                                  $18
  125    45        INIT_METHOD_CALL                                         'trim'
         46        SEND_VAR_EX                                              !4
         47        SEND_VAL_EX                                              8
         48        SEND_VAL_EX                                              '0'
         49        DO_FCALL                                      0  $28     
         50        ASSIGN                                                   !4, $28
  127    51        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cexplode'
         52        SEND_VAL_EX                                              '+'
         53        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Ctrim'
         54        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cchunk_split'
         55        SEND_VAR_EX                                              !4
         56        SEND_VAL_EX                                              8
         57        SEND_VAL_EX                                              '+'
         58        DO_FCALL                                      0  $30     
         59        SEND_VAR_NO_REF_EX                                       $30
         60        DO_FCALL                                      0  $31     
         61        SEND_VAR_NO_REF_EX                                       $31
         62        DO_FCALL                                      0  $32     
         63        ASSIGN                                                   !6, $32
  129    64      > FE_RESET_R                                       $34     !6, ->74
         65    > > FE_FETCH_R                                               $34, !7, ->74
  130    66    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cchr'
         67        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cbindec'
         68        SEND_VAR_EX                                              !7
         69        DO_FCALL                                      0  $35     
         70        SEND_VAR_NO_REF_EX                                       $35
         71        DO_FCALL                                      0  $36     
         72        ASSIGN_OP                                     8          !2, $36
  129    73      > JMP                                                      ->65
         74    >   FE_FREE                                                  $34
  134    75    > > RETURN                                                   !2
  135    76*     > RETURN                                                   null

End of function decode

Function pad:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/Cn051
function name:  pad
number of ops:  25
compiled vars:  !0 = $string, !1 = $factor, !2 = $char, !3 = $output, !4 = $length, !5 = $modulo, !6 = $outputPaddedLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  144     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
  146     3        ASSIGN                                                   !3, !0
  147     4        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstrlen'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $8      
          7        ASSIGN                                                   !4, $8
  148     8        MOD                                              ~10     !4, !1
          9        ASSIGN                                                   !5, ~10
  149    10        IS_NOT_EQUAL                                             !5, 0
         11      > JMPZ                                                     ~12, ->23
  150    12    >   SUB                                              ~13     !1, !5
         13        ADD                                              ~14     !4, ~13
         14        ASSIGN                                                   !6, ~14
  151    15        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstr_pad'
         16        SEND_VAR_EX                                              !3
         17        SEND_VAR_EX                                              !6
         18        SEND_VAR_EX                                              !2
         19        FETCH_CONSTANT                                   ~16     'Katoga%5CAllyourbase%5CSTR_PAD_RIGHT'
         20        SEND_VAL_EX                                              ~16
         21        DO_FCALL                                      0  $17     
         22        ASSIGN                                                   !3, $17
  154    23    > > RETURN                                                   !3
  155    24*     > RETURN                                                   null

End of function pad

Function trim:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 20
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/Cn051
function name:  trim
number of ops:  22
compiled vars:  !0 = $string, !1 = $factor, !2 = $char, !3 = $output, !4 = $length, !5 = $modulo, !6 = $outputTrimmedLength
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  164     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
  166     3        ASSIGN                                                   !3, !0
  167     4        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Cstrlen'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0  $8      
          7        ASSIGN                                                   !4, $8
  168     8        MOD                                              ~10     !4, !1
          9        ASSIGN                                                   !5, ~10
  169    10        IS_NOT_EQUAL                                             !5, 0
         11      > JMPZ                                                     ~12, ->20
  170    12    >   SUB                                              ~13     !4, !5
         13        ASSIGN                                                   !6, ~13
  171    14        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Csubstr'
         15        SEND_VAR_EX                                              !3
         16        SEND_VAL_EX                                              0
         17        SEND_VAR_EX                                              !6
         18        DO_FCALL                                      0  $15     
         19        ASSIGN                                                   !3, $15
  174    20    > > RETURN                                                   !3
  175    21*     > RETURN                                                   null

End of function trim

Function getencodingalphabet:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cn051
function name:  getEncodingAlphabet
number of ops:  7
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  181     0  E >   RECV                                             !0      
  183     1        FETCH_CLASS_CONSTANT                             ~3      'ENCODE'
          2        FETCH_OBJ_R                                      ~1      'alphabet'
          3        FETCH_DIM_R                                      ~2      ~1, !0
          4        FETCH_DIM_R                                      ~4      ~2, ~3
          5      > RETURN                                                   ~4
  184     6*     > RETURN                                                   null

End of function getencodingalphabet

Function getdecodingalphabet:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Cn051
function name:  getDecodingAlphabet
number of ops:  8
compiled vars:  !0 = $type
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  190     0  E >   RECV                                             !0      
  192     1        INIT_METHOD_CALL                                         'getAlphabet'
          2        SEND_VAR_EX                                              !0
          3        FETCH_CLASS_CONSTANT                             ~1      'DECODE'
          4        SEND_VAL_EX                                              ~1
          5        DO_FCALL                                      0  $2      
          6      > RETURN                                                   $2
  193     7*     > RETURN                                                   null

End of function getdecodingalphabet

Function getalphabet:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 14
Branch analysis from position: 6
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 27
Branch analysis from position: 19
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 135
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 41
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 64
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 87
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 87
2 jumps found. (Code = 77) Position 1 = 120, Position 2 = 128
Branch analysis from position: 120
2 jumps found. (Code = 78) Position 1 = 121, Position 2 = 128
Branch analysis from position: 121
1 jumps found. (Code = 42) Position 1 = 120
Branch analysis from position: 120
Branch analysis from position: 128
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
Branch analysis from position: 128
Branch analysis from position: 64
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 135
Branch analysis from position: 135
Branch analysis from position: 135
filename:       /in/Cn051
function name:  getAlphabet
number of ops:  140
compiled vars:  !0 = $type, !1 = $mode, !2 = $alphabet, !3 = $decodeCrockford, !4 = $lowercase, !5 = $ch
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  201     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  203     2        FETCH_OBJ_IS                                     ~6      'alphabet'
          3        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      ~6, !0
          4        BOOL_NOT                                         ~8      ~7
          5      > JMPZ                                                     ~8, ->14
  204     6    >   NEW                                              $9      'Katoga%5CAllyourbase%5CInvalidArgumentException'
          7        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Csprintf'
          8        SEND_VAL_EX                                              'Wrong+alphabet+requested%3A+%22%25s%22%21'
          9        SEND_VAR_EX                                              !0
         10        DO_FCALL                                      0  $10     
         11        SEND_VAR_NO_REF_EX                                       $10
         12        DO_FCALL                                      0          
         13      > THROW                                         0          $9
  207    14    >   FETCH_OBJ_IS                                     ~12     'alphabet'
         15        FETCH_DIM_IS                                     ~13     ~12, !0
         16        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     ~13, !1
         17        BOOL_NOT                                         ~15     ~14
         18      > JMPZ                                                     ~15, ->27
  208    19    >   NEW                                              $16     'Katoga%5CAllyourbase%5CInvalidArgumentException'
         20        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Csprintf'
         21        SEND_VAL_EX                                              'Wrong+mode+requested%3A+%22%25s%22%21'
         22        SEND_VAR_EX                                              !1
         23        DO_FCALL                                      0  $17     
         24        SEND_VAR_NO_REF_EX                                       $17
         25        DO_FCALL                                      0          
         26      > THROW                                         0          $16
  211    27    >   FETCH_OBJ_IS                                     ~19     'alphabet'
         28        FETCH_DIM_IS                                     ~20     ~19, !0
         29        ISSET_ISEMPTY_DIM_OBJ                         1          ~20, !1
         30      > JMPZ                                                     ~21, ->135
  214    31    >   FETCH_CLASS_CONSTANT                             ~23     'RFC4648'
         32        IS_EQUAL                                                 !0, ~23
         33      > JMPNZ                                                    ~22, ->41
  223    34    >   FETCH_CLASS_CONSTANT                             ~24     'RFC2938'
         35        IS_EQUAL                                                 !0, ~24
         36      > JMPNZ                                                    ~22, ->64
  232    37    >   FETCH_CLASS_CONSTANT                             ~25     'CROCKFORD'
         38        IS_EQUAL                                                 !0, ~25
         39      > JMPNZ                                                    ~22, ->87
         40    > > JMP                                                      ->135
  215    41    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Carray_merge'
  216    42        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Crange'
         43        SEND_VAL_EX                                              'A'
         44        SEND_VAL_EX                                              'Z'
         45        DO_FCALL                                      0  $26     
         46        SEND_VAR_NO_REF_EX                                       $26
  217    47        SEND_VAL_EX                                              <array>
         48        DO_FCALL                                      0  $27     
  215    49        ASSIGN                                                   !2, $27
  219    50        FETCH_CLASS_CONSTANT                             ~31     'ENCODE'
         51        FETCH_OBJ_W                                      $29     'alphabet'
         52        FETCH_DIM_W                                      $30     $29, !0
         53        ASSIGN_DIM                                               $30, ~31
         54        OP_DATA                                                  !2
  220    55        FETCH_CLASS_CONSTANT                             ~35     'DECODE'
         56        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Carray_flip'
         57        SEND_VAR_EX                                              !2
         58        DO_FCALL                                      0  $37     
         59        FETCH_OBJ_W                                      $33     'alphabet'
         60        FETCH_DIM_W                                      $34     $33, !0
         61        ASSIGN_DIM                                               $34, ~35
         62        OP_DATA                                                  $37
  221    63      > JMP                                                      ->135
  224    64    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Carray_merge'
  225    65        SEND_VAL_EX                                              <array>
  226    66        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Crange'
         67        SEND_VAL_EX                                              'A'
         68        SEND_VAL_EX                                              'V'
         69        DO_FCALL                                      0  $38     
         70        SEND_VAR_NO_REF_EX                                       $38
         71        DO_FCALL                                      0  $39     
  224    72        ASSIGN                                                   !2, $39
  228    73        FETCH_CLASS_CONSTANT                             ~43     'ENCODE'
         74        FETCH_OBJ_W                                      $41     'alphabet'
         75        FETCH_DIM_W                                      $42     $41, !0
         76        ASSIGN_DIM                                               $42, ~43
         77        OP_DATA                                                  !2
  229    78        FETCH_CLASS_CONSTANT                             ~47     'DECODE'
         79        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Carray_flip'
         80        SEND_VAR_EX                                              !2
         81        DO_FCALL                                      0  $49     
         82        FETCH_OBJ_W                                      $45     'alphabet'
         83        FETCH_DIM_W                                      $46     $45, !0
         84        ASSIGN_DIM                                               $46, ~47
         85        OP_DATA                                                  $49
  230    86      > JMP                                                      ->135
  233    87    >   INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Carray_merge'
  234    88        SEND_VAL_EX                                              <array>
  235    89        INIT_NS_FCALL_BY_NAME                                    'Katoga%5CAllyourbase%5Carray_diff'
  2

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.68 ms | 1428 KiB | 49 Q