3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Core\component\time; final class TimeFactory { /** @var int */ private $year; /** @var int */ private $weekNumber; /** @var int */ private $day; /** @var int */ private $hour; /** @var int */ private $minute; /** * @param string $formatted * @return static */ public static function createFromString(string $formatted): self { if (!preg_match('/^(\d{4}):(\d{2}):(\d{1}):(\d{2}):(\d{2})$/', $formatted, $matches)) { throw new \InvalidArgumentException('Invalid currency format.'); } return new self(...array_slice($matches, 1)); } /** * TimeFactory constructor. * @param int $year * @param int $weekNumber * @param int $day * @param int $hour * @param int $minute */ public function __construct(int $year, int $weekNumber, int $day, int $hour, int $minute) { $this->year = $year; $this->weekNumber = $weekNumber; $this->day = $day; $this->hour = $hour; $this->minute = $minute; } /** * @param int $addedYears * @return bool */ public function addYears(int $addedYears): bool { $newYears = $this->year + $addedYears; if($newYears > 9999) { return false; } else { $this->year += $newYears; } return true; } /** * @param int $addedWeeks */ public function addWeeks(int $addedWeeks): void { $newWeeks = $this->weekNumber + $addedWeeks; if($newWeeks >= 52) { $years = round($newWeeks / 52, 0, PHP_ROUND_HALF_DOWN); $this->addYears($years); } $this->weekNumber += $newWeeks % 52; } /** * @param int $addedDays */ public function addDays(int $addedDays): void { $newDays = $this->day + $addedDays; if($newDays >= 7) { $weeks = round($newDays / 7, 0, PHP_ROUND_HALF_DOWN); $this->addWeeks($weeks); } $this->day += $newDays % 7; } /** * @param int $addedHours */ public function addHours(int $addedHours): void { $newHours = $this->hour + $addedHours; if($newHours >= 24) { $days = round($newHours / 24, 0, PHP_ROUND_HALF_DOWN); $this->addDays($days); } $this->hour += $newHours % 24; } /** * @param int $addedMinutes */ public function addMinutes(int $addedMinutes): void { $newMinutes = $this->minute + $addedMinutes; if($newMinutes >= 60) { $hours = round($newMinutes / 60, 0, PHP_ROUND_HALF_DOWN); $this->addHours($hours); } $this->minute += $newMinutes % 60; } /** * @return int */ public function getYears(): int { return $this->year; } /** * @return int */ public function getWeeks(): int { return $this->weekNumber; } /** * @return int */ public function getDays(): int { return $this->day; } /** * @return int */ public function getHours(): int { return $this->hour; } /** * @return int */ public function getMinutes(): int { return $this->minute; } public function reduceTime(Int $amount, String $type) : bool { switch($type) { case "m": if($this->getMinutes() >= $amount) { $this->minute -= $amount; return true; } else { if($this->getHours() > 0) { $this->hour -= 1; $minutesToAdd = 60 - $amount; $this->addMinutes($minutesToAdd); return true; } elseif ($this->getDays() > 0) { $this->day -= 1; $hoursToAdd = 23; $minutesToAdd = 60 - $amount; $this->addHours($hoursToAdd); $this->addMinutes($minutesToAdd); return true; } elseif ($this->getWeeks() > 0) { $this->weekNumber -= 1; $daysToAdd = 6; $hoursToAdd = 23; $minutesToAdd = 60 - $amount; $this->addDays($daysToAdd); $this->addHours($hoursToAdd); $this->addMinutes($minutesToAdd); return true; } elseif ($this->getYears() > 0) { $this->year -= 1; $weeksToAdd = 51; $daysToAdd = 6; $hoursToAdd = 23; $minutesToAdd = 60 - $amount; $this->addWeeks($weeksToAdd); $this->addDays($daysToAdd); $this->addHours($hoursToAdd); $this->addMinutes($minutesToAdd); return true; } } break; case "h": if($this->getHours() >= $amount) { $this->hour -= $amount; return true; } else { if ($this->getDays() > 0) { $this->day -= 1; $hoursToAdd = 24 - $amount; $this->addHours($hoursToAdd); return true; } elseif ($this->getWeeks() > 0) { $this->weekNumber -= 1; $daysToAdd = 6; $hoursToAdd = 24 - $amount; $this->addDays($daysToAdd); $this->addHours($hoursToAdd); return true; } elseif ($this->getYears() > 0) { $this->year -= 1; $weeksToAdd = 51; $daysToAdd = 6; $hoursToAdd = 24 - $amount; $this->addWeeks($weeksToAdd); $this->addDays($daysToAdd); $this->addHours($hoursToAdd); return true; } } break; case "d": if($this->getDays() >= $amount) { $this->day -= $amount; return true; } else { if ($this->getWeeks() > 0) { $this->weekNumber--; $daysToAdd = 7 - $amount; $this->addDays($daysToAdd); return true; } elseif ($this->getYears() > 0) { $this->year--; $weeksToAdd = 51; $daysToAdd = 7 - $amount; $this->addWeeks($weeksToAdd); $this->addDays($daysToAdd); return true; } } break; case "w": if($this->getWeeks() >= $amount) { $this->weekNumber -= $amount; return true; } else { if ($this->getYears() > 0) { $weeksToAdd = 52 - $amount; $this->addWeeks($weeksToAdd); return true; } } break; case "y": if($this->getYears() >= $amount) { $this->year -= $amount; return true; } } return false; } /** * @return string */ public function __toString(): string { return sprintf('%04d:%02d:%d:%02d:%02d', $this->year, $this->weekNumber, $this->day, $this->hour, $this->minute); } } $factory = TimeFactory::createFromString("0000:00:0:00:00"); $factory->addMinutes(2); $factory->addMinutes(4); $factory->addMinutes(6); $factory->addMinutes(8); $factory->addMinutes(10); $factory->addMinutes(12); echo $factory; echo "\n" . $factory->getMinutes(); echo "\n" . $factory->getHours(); echo "\n" . $factory->getDays(); echo "\n" . $factory->getWeeks(); echo "\n" . $factory->getYears();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  (null)
number of ops:  45
compiled vars:  !0 = $factory
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   DECLARE_CLASS                                            'core%5Ccomponent%5Ctime%5Ctimefactory'
  262     1        INIT_STATIC_METHOD_CALL                                  'Core%5Ccomponent%5Ctime%5CTimeFactory', 'createFromString'
          2        SEND_VAL_EX                                              '0000%3A00%3A0%3A00%3A00'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
  263     5        INIT_METHOD_CALL                                         !0, 'addMinutes'
          6        SEND_VAL_EX                                              2
          7        DO_FCALL                                      0          
  264     8        INIT_METHOD_CALL                                         !0, 'addMinutes'
          9        SEND_VAL_EX                                              4
         10        DO_FCALL                                      0          
  265    11        INIT_METHOD_CALL                                         !0, 'addMinutes'
         12        SEND_VAL_EX                                              6
         13        DO_FCALL                                      0          
  266    14        INIT_METHOD_CALL                                         !0, 'addMinutes'
         15        SEND_VAL_EX                                              8
         16        DO_FCALL                                      0          
  267    17        INIT_METHOD_CALL                                         !0, 'addMinutes'
         18        SEND_VAL_EX                                              10
         19        DO_FCALL                                      0          
  268    20        INIT_METHOD_CALL                                         !0, 'addMinutes'
         21        SEND_VAL_EX                                              12
         22        DO_FCALL                                      0          
  270    23        ECHO                                                     !0
  271    24        INIT_METHOD_CALL                                         !0, 'getMinutes'
         25        DO_FCALL                                      0  $9      
         26        CONCAT                                           ~10     '%0A', $9
         27        ECHO                                                     ~10
  272    28        INIT_METHOD_CALL                                         !0, 'getHours'
         29        DO_FCALL                                      0  $11     
         30        CONCAT                                           ~12     '%0A', $11
         31        ECHO                                                     ~12
  273    32        INIT_METHOD_CALL                                         !0, 'getDays'
         33        DO_FCALL                                      0  $13     
         34        CONCAT                                           ~14     '%0A', $13
         35        ECHO                                                     ~14
  274    36        INIT_METHOD_CALL                                         !0, 'getWeeks'
         37        DO_FCALL                                      0  $15     
         38        CONCAT                                           ~16     '%0A', $15
         39        ECHO                                                     ~16
  275    40        INIT_METHOD_CALL                                         !0, 'getYears'
         41        DO_FCALL                                      0  $17     
         42        CONCAT                                           ~18     '%0A', $17
         43        ECHO                                                     ~18
         44      > RETURN                                                   1

Class Core\component\time\TimeFactory:
Function createfromstring:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  createFromString
number of ops:  24
compiled vars:  !0 = $formatted, !1 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        INIT_NS_FCALL_BY_NAME                                    'Core%5Ccomponent%5Ctime%5Cpreg_match'
          2        SEND_VAL_EX                                              '%2F%5E%28%5Cd%7B4%7D%29%3A%28%5Cd%7B2%7D%29%3A%28%5Cd%7B1%7D%29%3A%28%5Cd%7B2%7D%29%3A%28%5Cd%7B2%7D%29%24%2F'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAR_EX                                              !1
          5        DO_FCALL                                      0  $2      
          6        BOOL_NOT                                         ~3      $2
          7      > JMPZ                                                     ~3, ->12
   24     8    >   NEW                                              $4      'InvalidArgumentException'
          9        SEND_VAL_EX                                              'Invalid+currency+format.'
         10        DO_FCALL                                      0          
         11      > THROW                                         0          $4
   26    12    >   NEW                          self                $6      
         13        INIT_NS_FCALL_BY_NAME                                    'Core%5Ccomponent%5Ctime%5Carray_slice'
         14        SEND_VAR_EX                                              !1
         15        SEND_VAL_EX                                              1
         16        DO_FCALL                                      0  $7      
         17        SEND_UNPACK                                              $7
         18        CHECK_UNDEF_ARGS                                         
         19        DO_FCALL                                      1          
         20        VERIFY_RETURN_TYPE                                       $6
         21      > RETURN                                                   $6
   27    22*       VERIFY_RETURN_TYPE                                       
         23*     > RETURN                                                   null

End of function createfromstring

Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  __construct
number of ops:  16
compiled vars:  !0 = $year, !1 = $weekNumber, !2 = $day, !3 = $hour, !4 = $minute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
   40     5        ASSIGN_OBJ                                               'year'
          6        OP_DATA                                                  !0
   41     7        ASSIGN_OBJ                                               'weekNumber'
          8        OP_DATA                                                  !1
   42     9        ASSIGN_OBJ                                               'day'
         10        OP_DATA                                                  !2
   43    11        ASSIGN_OBJ                                               'hour'
         12        OP_DATA                                                  !3
   44    13        ASSIGN_OBJ                                               'minute'
         14        OP_DATA                                                  !4
   45    15      > RETURN                                                   null

End of function __construct

Function addyears:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 8
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  addYears
number of ops:  13
compiled vars:  !0 = $addedYears, !1 = $newYears
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
   52     1        FETCH_OBJ_R                                      ~2      'year'
          2        ADD                                              ~3      ~2, !0
          3        ASSIGN                                                   !1, ~3
   53     4        IS_SMALLER                                               9999, !1
          5      > JMPZ                                                     ~5, ->8
   54     6    > > RETURN                                                   <false>
          7*       JMP                                                      ->10
   56     8    >   ASSIGN_OBJ_OP                                 1          'year'
          9        OP_DATA                                                  !1
   58    10      > RETURN                                                   <true>
   59    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function addyears

Function addweeks:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/YiEQF
function name:  addWeeks
number of ops:  21
compiled vars:  !0 = $addedWeeks, !1 = $newWeeks, !2 = $years
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
   65     1        FETCH_OBJ_R                                      ~3      'weekNumber'
          2        ADD                                              ~4      ~3, !0
          3        ASSIGN                                                   !1, ~4
   66     4        IS_SMALLER_OR_EQUAL                                      52, !1
          5      > JMPZ                                                     ~6, ->17
   67     6    >   INIT_NS_FCALL_BY_NAME                                    'Core%5Ccomponent%5Ctime%5Cround'
          7        DIV                                              ~7      !1, 52
          8        SEND_VAL_EX                                              ~7
          9        SEND_VAL_EX                                              0
         10        FETCH_CONSTANT                                   ~8      'Core%5Ccomponent%5Ctime%5CPHP_ROUND_HALF_DOWN'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
   68    14        INIT_METHOD_CALL                                         'addYears'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   70    17    >   MOD                                              ~13     !1, 52
         18        ASSIGN_OBJ_OP                                 1          'weekNumber'
         19        OP_DATA                                                  ~13
   71    20      > RETURN                                                   null

End of function addweeks

Function adddays:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/YiEQF
function name:  addDays
number of ops:  21
compiled vars:  !0 = $addedDays, !1 = $newDays, !2 = $weeks
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV                                             !0      
   77     1        FETCH_OBJ_R                                      ~3      'day'
          2        ADD                                              ~4      ~3, !0
          3        ASSIGN                                                   !1, ~4
   78     4        IS_SMALLER_OR_EQUAL                                      7, !1
          5      > JMPZ                                                     ~6, ->17
   79     6    >   INIT_NS_FCALL_BY_NAME                                    'Core%5Ccomponent%5Ctime%5Cround'
          7        DIV                                              ~7      !1, 7
          8        SEND_VAL_EX                                              ~7
          9        SEND_VAL_EX                                              0
         10        FETCH_CONSTANT                                   ~8      'Core%5Ccomponent%5Ctime%5CPHP_ROUND_HALF_DOWN'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
   80    14        INIT_METHOD_CALL                                         'addWeeks'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   82    17    >   MOD                                              ~13     !1, 7
         18        ASSIGN_OBJ_OP                                 1          'day'
         19        OP_DATA                                                  ~13
   83    20      > RETURN                                                   null

End of function adddays

Function addhours:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/YiEQF
function name:  addHours
number of ops:  21
compiled vars:  !0 = $addedHours, !1 = $newHours, !2 = $days
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   88     0  E >   RECV                                             !0      
   89     1        FETCH_OBJ_R                                      ~3      'hour'
          2        ADD                                              ~4      ~3, !0
          3        ASSIGN                                                   !1, ~4
   90     4        IS_SMALLER_OR_EQUAL                                      24, !1
          5      > JMPZ                                                     ~6, ->17
   91     6    >   INIT_NS_FCALL_BY_NAME                                    'Core%5Ccomponent%5Ctime%5Cround'
          7        DIV                                              ~7      !1, 24
          8        SEND_VAL_EX                                              ~7
          9        SEND_VAL_EX                                              0
         10        FETCH_CONSTANT                                   ~8      'Core%5Ccomponent%5Ctime%5CPHP_ROUND_HALF_DOWN'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
   92    14        INIT_METHOD_CALL                                         'addDays'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   94    17    >   MOD                                              ~13     !1, 24
         18        ASSIGN_OBJ_OP                                 1          'hour'
         19        OP_DATA                                                  ~13
   95    20      > RETURN                                                   null

End of function addhours

Function addminutes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/YiEQF
function name:  addMinutes
number of ops:  21
compiled vars:  !0 = $addedMinutes, !1 = $newMinutes, !2 = $hours
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  100     0  E >   RECV                                             !0      
  101     1        FETCH_OBJ_R                                      ~3      'minute'
          2        ADD                                              ~4      ~3, !0
          3        ASSIGN                                                   !1, ~4
  102     4        IS_SMALLER_OR_EQUAL                                      60, !1
          5      > JMPZ                                                     ~6, ->17
  103     6    >   INIT_NS_FCALL_BY_NAME                                    'Core%5Ccomponent%5Ctime%5Cround'
          7        DIV                                              ~7      !1, 60
          8        SEND_VAL_EX                                              ~7
          9        SEND_VAL_EX                                              0
         10        FETCH_CONSTANT                                   ~8      'Core%5Ccomponent%5Ctime%5CPHP_ROUND_HALF_DOWN'
         11        SEND_VAL_EX                                              ~8
         12        DO_FCALL                                      0  $9      
         13        ASSIGN                                                   !2, $9
  104    14        INIT_METHOD_CALL                                         'addHours'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
  106    17    >   MOD                                              ~13     !1, 60
         18        ASSIGN_OBJ_OP                                 1          'minute'
         19        OP_DATA                                                  ~13
  107    20      > RETURN                                                   null

End of function addminutes

Function getyears:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  getYears
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  113     0  E >   FETCH_OBJ_R                                      ~0      'year'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
  114     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getyears

Function getweeks:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  getWeeks
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  120     0  E >   FETCH_OBJ_R                                      ~0      'weekNumber'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
  121     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getweeks

Function getdays:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  getDays
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  127     0  E >   FETCH_OBJ_R                                      ~0      'day'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
  128     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getdays

Function gethours:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  getHours
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  134     0  E >   FETCH_OBJ_R                                      ~0      'hour'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
  135     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function gethours

Function getminutes:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiEQF
function name:  getMinutes
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  141     0  E >   FETCH_OBJ_R                                      ~0      'minute'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
  142     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getminutes

Function reducetime:
Finding entry points
Branch analysis from position: 0
7 jumps found. (Code = 188) Position 1 = 14, Position 2 = 98, Position 3 = 157, Position 4 = 193, Position 5 = 212, Position 6 = 219, Position 7 = 3
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 35
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 52
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 52
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 73
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 97
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
1 jumps found. (Code = 42) Position 1 = 219
Branch analysis from position: 219
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 98
2 jumps found. (Code = 43) Position 1 = 102, Position 2 = 106
Branch analysis from position: 102
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 106
2 jumps found. (Code = 43) Position 1 = 110, Position 2 = 119
Branch analysis from position: 110
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 119
2 jumps found. (Code = 43) Position 1 = 123, Position 2 = 136
Branch analysis from position: 123
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 136
2 jumps found. (Code = 43) Position 1 = 140, Position 2 = 156
Branch analysis from position: 140
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 156
1 jumps found. (Code = 42) Position 1 = 219
Branch analysis from position: 219
Branch analysis from position: 157
2 jumps found. (Code = 43) Position 1 = 161, Position 2 = 165
Branch analysis from position: 161
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 165
2 jumps found. (Code = 43) Position 1 = 169, Position 2 = 177
Branch analysis from position: 169
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 177
2 jumps found. (Code = 43) Position 1 = 181, Position 2 = 192
Branch analysis from position: 181
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 192
1 jumps found. (Code = 42) Position 1 = 219
Branch analysis from position: 219
Branch analysis from position: 193
2 jumps found. (Code = 43) Position 1 = 197, Position 2 = 201
Branch analysis from position: 197
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 201
2 jumps found. (Code = 43) Position 1 = 205, Position 2 = 211
Branch analysis from position: 205
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 211
1 jumps found. (Code = 42) Position 1 = 219
Branch analysis from position: 219
Branch analysis from position: 212
2 jumps found. (Code = 43) Position 1 = 216, Position 2 = 219
Branch analysis from position: 216
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 219
Branch analysis from position: 219
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 44) Position 1 = 7, Position 2 = 98
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 9, Position 2 = 157
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 193
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 13, Position 2 = 212
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 219
Branch analysis from position: 219
Branch analysis from position: 212
Branch analysis from position: 193
Branch analysis from position: 157
Branch analysis from position: 98
Branch analysis from position: 14
filename:       /in/YiEQF
function name:  reduceTime
number of ops:  222
compiled vars:  !0 = $amount, !1 = $type, !2 = $minutesToAdd, !3 = $hoursToAdd, !4 = $daysToAdd, !5 = $weeksToAdd
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  144     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  145     2      > SWITCH_STRING                                            !1, [ 'm':->14, 'h':->98, 'd':->157, 'w':->193, 'y':->212, ], ->219
  146     3    >   IS_EQUAL                                                 !1, 'm'
          4      > JMPNZ                                                    ~6, ->14
  186     5    >   IS_EQUAL                                                 !1, 'h'
          6      > JMPNZ                                                    ~6, ->98
  215     7    >   IS_EQUAL                                                 !1, 'd'
          8      > JMPNZ                                                    ~6, ->157
  235     9    >   IS_EQUAL                                                 !1, 'w'
         10      > JMPNZ                                                    ~6, ->193
  247    11    >   IS_EQUAL                                                 !1, 'y'
         12      > JMPNZ                                                    ~6, ->212
         13    > > JMP                                                      ->219
  147    14    >   INIT_METHOD_CALL                                         'getMinutes'
         15        DO_FCALL                                      0  $7      
         16        IS_SMALLER_OR_EQUAL                                      !0, $7
         17      > JMPZ                                                     ~8, ->22
  148    18    >   ASSIGN_OBJ_OP                                 2          'minute'
         19        OP_DATA                                                  !0
  149    20      > RETURN                                                   <true>
         21*       JMP                                                      ->97
  151    22    >   INIT_METHOD_CALL                                         'getHours'
         23        DO_FCALL                                      0  $10     
         24        IS_SMALLER                                               0, $10
         25      > JMPZ                                                     ~11, ->35
  152    26    >   ASSIGN_OBJ_OP                                 2          'hour'
         27        OP_DATA                                                  1
  153    28        SUB                                              ~13     60, !0
         29        ASSIGN                                                   !2, ~13
  154    30        INIT_METHOD_CALL                                         'addMinutes'
         31        SEND_VAR_EX                                              !2
         32        DO_FCALL                                      0          
  155    33      > RETURN                                                   <true>
         34*       JMP                                                      ->97
  156    35    >   INIT_METHOD_CALL                                         'getDays'
         36        DO_FCALL                                      0  $16     
         37        IS_SMALLER                                               0, $16
         38      > JMPZ                                                     ~17, ->52
  157    39    >   ASSIGN_OBJ_OP                                 2          'day'
         40        OP_DATA                                                  1
  158    41        ASSIGN                                                   !3, 23
  159    42        SUB                                              ~20     60, !0
         43        ASSIGN                                                   !2, ~20
  160    44        INIT_METHOD_CALL                                         'addHours'
         45        SEND_VAR_EX                                              !3
         46        DO_FCALL                                      0          
  161    47        INIT_METHOD_CALL                                         'addMinutes'
         48        SEND_VAR_EX                                              !2
         49        DO_FCALL                                      0          
  162    50      > RETURN                                                   <true>
         51*       JMP                                                      ->97
  163    52    >   INIT_METHOD_CALL                                         'getWeeks'
         53        DO_FCALL          

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
288.2 ms | 1432 KiB | 20 Q