3v4l.org

run code in 300+ PHP versions simultaneously
<?php // camel case the class name class Smth { // changed the static class variables to constants const MARK_UNDEFINED = 'Undefined'; const MARK_F = 'ECTS-F'; const MARK_FX = 'ECTS-FX'; const MARK_E = 'ECTS-E'; const MARK_D = 'ECTS-D'; const MARK_C = 'ECTS-C'; const MARK_B = 'ECTS-B'; const MARK_A = 'ECTS-A'; // changed the protected method to public(no discernable reason to make it protected) // changed the function name to camel case public function getEctsMark($rate, $current, $examRate) { // moved this here to save us going through 2 if statements if($current > 0 && $examRate < 22) { return self::MARK_FX; } // the rest is the same as it was originally. $color = self::MARK_UNDEFINED; if ($current > 0) { $percent = $rate / $current; if ($percent < 0.31) { $color = self::MARK_F; } elseif ($percent < 0.60) { $color = self::MARK_FX; } elseif ($percent < 0.65) { $color = self::MARK_E; } elseif ($percent < 0.71) { $color = self::MARK_D; } elseif ($percent < 0.85) { $color = self::MARK_C; } elseif ($percent < 0.95) { $color = self::MARK_B; } else { $color = self::MARK_A; } } return $color; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QuveB
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E > > RETURN                                                   1

Class Smth:
Function getectsmark:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 39
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 22
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 30
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 34
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 7
filename:       /in/QuveB
function name:  getEctsMark
number of ops:  41
compiled vars:  !0 = $rate, !1 = $current, !2 = $examRate, !3 = $color, !4 = $percent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   21     3        IS_SMALLER                                       ~5      0, !1
          4      > JMPZ_EX                                          ~5      ~5, ->7
          5    >   IS_SMALLER                                       ~6      !2, 22
          6        BOOL                                             ~5      ~6
          7    > > JMPZ                                                     ~5, ->9
   22     8    > > RETURN                                                   'ECTS-FX'
   26     9    >   ASSIGN                                                   !3, 'Undefined'
   28    10        IS_SMALLER                                               0, !1
         11      > JMPZ                                                     ~8, ->39
   29    12    >   DIV                                              ~9      !0, !1
         13        ASSIGN                                                   !4, ~9
   31    14        IS_SMALLER                                               !4, 0.31
         15      > JMPZ                                                     ~11, ->18
   32    16    >   ASSIGN                                                   !3, 'ECTS-F'
   31    17      > JMP                                                      ->39
   33    18    >   IS_SMALLER                                               !4, 0.6
         19      > JMPZ                                                     ~13, ->22
   34    20    >   ASSIGN                                                   !3, 'ECTS-FX'
   33    21      > JMP                                                      ->39
   35    22    >   IS_SMALLER                                               !4, 0.65
         23      > JMPZ                                                     ~15, ->26
   36    24    >   ASSIGN                                                   !3, 'ECTS-E'
   35    25      > JMP                                                      ->39
   37    26    >   IS_SMALLER                                               !4, 0.71
         27      > JMPZ                                                     ~17, ->30
   38    28    >   ASSIGN                                                   !3, 'ECTS-D'
   37    29      > JMP                                                      ->39
   39    30    >   IS_SMALLER                                               !4, 0.85
         31      > JMPZ                                                     ~19, ->34
   40    32    >   ASSIGN                                                   !3, 'ECTS-C'
   39    33      > JMP                                                      ->39
   41    34    >   IS_SMALLER                                               !4, 0.95
         35      > JMPZ                                                     ~21, ->38
   42    36    >   ASSIGN                                                   !3, 'ECTS-B'
   41    37      > JMP                                                      ->39
   44    38    >   ASSIGN                                                   !3, 'ECTS-A'
   48    39    > > RETURN                                                   !3
   49    40*     > RETURN                                                   null

End of function getectsmark

End of class Smth.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.45 ms | 1002 KiB | 13 Q