3v4l.org

run code in 300+ PHP versions simultaneously
<?php $punch_in = "2019-07-01 09:00:00"; $punch_out = "2019-07-01 18:00:00"; $in_threshold = "2019-07-01 08:15:00"; $out_threshold = "2019-07-01 17:15:00"; $exact_in_threshold = "2019-07-01 08:00:00"; $exact_out_threshold = "2019-07-01 17:00:00"; function generateAttendance( $punch_in, $punch_out , $in_threshold, $out_threshold , $exact_in_threshold, $exact_out_threshold){ $lates = 0; $overtime = 0; // If punch_in is late = punch_in and late + 1 if ($punch_in > $in_threshold) { $start = $punch_in; $lates = +1; } // If punch_in is early = exact_time else { $start = $exact_in_threshold; } // If punch_out is early = punch_out if ($punch_out < $out_threshold) { $end = $punch_out; } // If pucn_out is overtime = exact_end and overtime + 1 else { $end = $exact_out_threshold; $overtime =1; } // If both punch in and punch_out is within threshold if ((( $exact_in_threshold >= $in_threshold ) && ( $exact_in_threshold <= $punch_in )) && (( $exact_out_threshold >= $out_threshold ) && ( $exact_out_threshold <= $punch_out ))) { $start = $punch_in; $end = $punch_out; } // If punch_in is within threshold, start = punch_in and end = exact_end else if ((( $exact_in_threshold >= $in_threshold ) && ( $exact_in_threshold <= $punch_in )) && $punch_out > $out_threshold) { $start = $punch_in; $end = $exact_out_threshold; } return array('start' => $start, 'end' => $end, 'lates' => $lates, 'overtime' => $overtime); } $result = generateAttendance( $punch_in, $punch_out , $in_threshold, $out_threshold , $exact_in_threshold, $exact_out_threshold); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/XDTsI
function name:  (null)
number of ops:  19
compiled vars:  !0 = $punch_in, !1 = $punch_out, !2 = $in_threshold, !3 = $out_threshold, !4 = $exact_in_threshold, !5 = $exact_out_threshold, !6 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '2019-07-01+09%3A00%3A00'
    4     1        ASSIGN                                                   !1, '2019-07-01+18%3A00%3A00'
    6     2        ASSIGN                                                   !2, '2019-07-01+08%3A15%3A00'
    7     3        ASSIGN                                                   !3, '2019-07-01+17%3A15%3A00'
    9     4        ASSIGN                                                   !4, '2019-07-01+08%3A00%3A00'
   10     5        ASSIGN                                                   !5, '2019-07-01+17%3A00%3A00'
   55     6        INIT_FCALL                                               'generateattendance'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        SEND_VAR                                                 !3
         11        SEND_VAR                                                 !4
         12        SEND_VAR                                                 !5
         13        DO_FCALL                                      0  $13     
         14        ASSIGN                                                   !6, $13
   57    15        INIT_FCALL                                               'print_r'
         16        SEND_VAR                                                 !6
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Function generateattendance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 34
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
2 jumps found. (Code = 46) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
2 jumps found. (Code = 46) Position 1 = 39, Position 2 = 41
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 44
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 41
Branch analysis from position: 38
Branch analysis from position: 29
Branch analysis from position: 30
Branch analysis from position: 24
Branch analysis from position: 18
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 24
Branch analysis from position: 22
Branch analysis from position: 24
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
Branch analysis from position: 18
filename:       /in/XDTsI
function name:  generateAttendance
number of ops:  50
compiled vars:  !0 = $punch_in, !1 = $punch_out, !2 = $in_threshold, !3 = $out_threshold, !4 = $exact_in_threshold, !5 = $exact_out_threshold, !6 = $lates, !7 = $overtime, !8 = $start, !9 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
          4        RECV                                             !4      
          5        RECV                                             !5      
   13     6        ASSIGN                                                   !6, 0
   14     7        ASSIGN                                                   !7, 0
   17     8        IS_SMALLER                                               !2, !0
          9      > JMPZ                                                     ~12, ->13
   18    10    >   ASSIGN                                                   !8, !0
   19    11        ASSIGN                                                   !6, 1
         12      > JMP                                                      ->14
   24    13    >   ASSIGN                                                   !8, !4
   28    14    >   IS_SMALLER                                               !1, !3
         15      > JMPZ                                                     ~16, ->18
   29    16    >   ASSIGN                                                   !9, !1
         17      > JMP                                                      ->20
   33    18    >   ASSIGN                                                   !9, !5
   34    19        ASSIGN                                                   !7, 1
   38    20    >   IS_SMALLER_OR_EQUAL                              ~20     !2, !4
         21      > JMPZ_EX                                          ~20     ~20, ->24
         22    >   IS_SMALLER_OR_EQUAL                              ~21     !4, !0
         23        BOOL                                             ~20     ~21
         24    > > JMPZ_EX                                          ~20     ~20, ->30
   39    25    >   IS_SMALLER_OR_EQUAL                              ~22     !3, !5
         26      > JMPZ_EX                                          ~22     ~22, ->29
         27    >   IS_SMALLER_OR_EQUAL                              ~23     !5, !1
         28        BOOL                                             ~22     ~23
         29    >   BOOL                                             ~20     ~22
         30    > > JMPZ                                                     ~20, ->34
   40    31    >   ASSIGN                                                   !8, !0
   41    32        ASSIGN                                                   !9, !1
         33      > JMP                                                      ->44
   45    34    >   IS_SMALLER_OR_EQUAL                              ~26     !2, !4
         35      > JMPZ_EX                                          ~26     ~26, ->38
         36    >   IS_SMALLER_OR_EQUAL                              ~27     !4, !0
         37        BOOL                                             ~26     ~27
         38    > > JMPZ_EX                                          ~26     ~26, ->41
         39    >   IS_SMALLER                                       ~28     !3, !1
         40        BOOL                                             ~26     ~28
         41    > > JMPZ                                                     ~26, ->44
   46    42    >   ASSIGN                                                   !8, !0
   47    43        ASSIGN                                                   !9, !5
   51    44    >   INIT_ARRAY                                       ~31     !8, 'start'
         45        ADD_ARRAY_ELEMENT                                ~31     !9, 'end'
         46        ADD_ARRAY_ELEMENT                                ~31     !6, 'lates'
         47        ADD_ARRAY_ELEMENT                                ~31     !7, 'overtime'
         48      > RETURN                                                   ~31
   53    49*     > RETURN                                                   null

End of function generateattendance

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.61 ms | 1407 KiB | 16 Q