3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything you enter here will be executed by our servers. Try it! class Contract { private $startDate; private $numberofDays; private $endDate; public function __construct($startDate, $numberofDays) { $this->startDate = \DateTime::createFromFormat('Y-m-d', $startDate); $this->numberofDays = $numberofDays; $this->endDate = $this->getEndDate(); } public function overLap(Contract $other) { $overlap = false; if($other->getEndDate() < $this->startDate || $other->getStartDate() > $this->endDate){ $overlap = true; } return $overlap; } /** * Given the start date of a contract will return the end date, skipping weekends * * @return Array of date strings */ public function getDeadline() { $start = (new \DateTime())->setTimestamp($this->startDate->getTimestamp()); $interval = new DateInterval('P1D'); $result = array(); $i = 0; while($i < $this->numberofDays){ if((int)$start->format('N') < 6){ $result[] = $start->format('Y-m-d'); $i++; } $start->add($interval); } return $result; } public function getEndDate() { if(!$this->endDate){ $dates = $this->getDeadline(); $this->endDate = end($dates); } return $this->endDate; } public function getStartDate() { return $this->startDate; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6sDi2
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E > > RETURN                                                   1

Class Contract:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6sDi2
function name:  __construct
number of ops:  15
compiled vars:  !0 = $startDate, !1 = $numberofDays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        INIT_STATIC_METHOD_CALL                                  'DateTime', 'createFromFormat'
          3        SEND_VAL                                                 'Y-m-d'
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $3      
          6        ASSIGN_OBJ                                               'startDate'
          7        OP_DATA                                                  $3
   13     8        ASSIGN_OBJ                                               'numberofDays'
          9        OP_DATA                                                  !1
   14    10        INIT_METHOD_CALL                                         'getEndDate'
         11        DO_FCALL                                      0  $6      
         12        ASSIGN_OBJ                                               'endDate'
         13        OP_DATA                                                  $6
   15    14      > RETURN                                                   null

End of function __construct

Function overlap:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
Branch analysis from position: 12
filename:       /in/6sDi2
function name:  overLap
number of ops:  16
compiled vars:  !0 = $other, !1 = $overlap
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        ASSIGN                                                   !1, <false>
   20     2        INIT_METHOD_CALL                                         !0, 'getEndDate'
          3        DO_FCALL                                      0  $3      
          4        FETCH_OBJ_R                                      ~4      'startDate'
          5        IS_SMALLER                                       ~5      $3, ~4
          6      > JMPNZ_EX                                         ~5      ~5, ->12
          7    >   INIT_METHOD_CALL                                         !0, 'getStartDate'
          8        DO_FCALL                                      0  $6      
          9        FETCH_OBJ_R                                      ~7      'endDate'
         10        IS_SMALLER                                       ~8      ~7, $6
         11        BOOL                                             ~5      ~8
         12    > > JMPZ                                                     ~5, ->14
   21    13    >   ASSIGN                                                   !1, <true>
   23    14    > > RETURN                                                   !1
   24    15*     > RETURN                                                   null

End of function overlap

Function getdeadline:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 16
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 28
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 16
Branch analysis from position: 34
Branch analysis from position: 16
Branch analysis from position: 28
filename:       /in/6sDi2
function name:  getDeadline
number of ops:  36
compiled vars:  !0 = $start, !1 = $interval, !2 = $result, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $4      'DateTime'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $4, 'setTimestamp'
          3        FETCH_OBJ_R                                      ~6      'startDate'
          4        INIT_METHOD_CALL                                         ~6, 'getTimestamp'
          5        DO_FCALL                                      0  $7      
          6        SEND_VAR_NO_REF_EX                                       $7
          7        DO_FCALL                                      0  $8      
          8        ASSIGN                                                   !0, $8
   34     9        NEW                                              $10     'DateInterval'
         10        SEND_VAL_EX                                              'P1D'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $10
   35    13        ASSIGN                                                   !2, <array>
   37    14        ASSIGN                                                   !3, 0
   38    15      > JMP                                                      ->31
   39    16    >   INIT_METHOD_CALL                                         !0, 'format'
         17        SEND_VAL_EX                                              'N'
         18        DO_FCALL                                      0  $15     
         19        CAST                                          4  ~16     $15
         20        IS_SMALLER                                               ~16, 6
         21      > JMPZ                                                     ~17, ->28
   40    22    >   INIT_METHOD_CALL                                         !0, 'format'
         23        SEND_VAL_EX                                              'Y-m-d'
         24        DO_FCALL                                      0  $19     
         25        ASSIGN_DIM                                               !2
         26        OP_DATA                                                  $19
   41    27        PRE_INC                                                  !3
   43    28    >   INIT_METHOD_CALL                                         !0, 'add'
         29        SEND_VAR_EX                                              !1
         30        DO_FCALL                                      0          
   38    31    >   FETCH_OBJ_R                                      ~22     'numberofDays'
         32        IS_SMALLER                                               !3, ~22
         33      > JMPNZ                                                    ~23, ->16
   45    34    > > RETURN                                                   !2
   46    35*     > RETURN                                                   null

End of function getdeadline

Function getenddate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 11
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/6sDi2
function name:  getEndDate
number of ops:  14
compiled vars:  !0 = $dates
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   50     0  E >   FETCH_OBJ_R                                      ~1      'endDate'
          1        BOOL_NOT                                         ~2      ~1
          2      > JMPZ                                                     ~2, ->11
   51     3    >   INIT_METHOD_CALL                                         'getDeadline'
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !0, $3
   52     6        INIT_FCALL                                               'end'
          7        SEND_REF                                                 !0
          8        DO_ICALL                                         $6      
          9        ASSIGN_OBJ                                               'endDate'
         10        OP_DATA                                                  $6
   54    11    >   FETCH_OBJ_R                                      ~7      'endDate'
         12      > RETURN                                                   ~7
   55    13*     > RETURN                                                   null

End of function getenddate

Function getstartdate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6sDi2
function name:  getStartDate
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   FETCH_OBJ_R                                      ~0      'startDate'
          1      > RETURN                                                   ~0
   60     2*     > RETURN                                                   null

End of function getstartdate

End of class Contract.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.23 ms | 1404 KiB | 15 Q