| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * @file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * Class ConstraintManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | namespace Roomify\Bat\Constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class ConstraintManager { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |   protected $constraints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |    * @param $constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |   public function __construct($constraints = array()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     $this->constraints = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     foreach ($constraints as $constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |       $this->constraints[get_class($constraint)][] = $constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |    * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |   public function getConstraints($constraint_class = NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     if ($constraint_class == NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |       return $this->constraint; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |       return $this->constraint[$constraint_class]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |    * @param $constraints | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 38 |  |  |    */ | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |   public function addConstraints($constraints) { | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     foreach ($constraints as $constraint) { | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |       $this->constraints[get_class($constraint)][] = $constraint; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |    * @param $constraints | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |   public function setConstraints($constraints) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     $this->constraints = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     $this->addConstraints($constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |    * @param $constraint_class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |    * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |    * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |   public function normalizeConstraints($constraint_class = NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     if ($constraint_class == NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |       $classes = array_keys($this->constraints); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |       $classes = array($constraint_class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     $new_constraints = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     foreach ($classes as $class) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |       switch ($class) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         case 'Roomify\Bat\Constraint\MinMaxDaysConstraint': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |           $new_constraints[$class] = $this->normalizeMinMaxDaysConstraints(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |           break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         case 'Roomify\Bat\Constraint\CheckInDayConstraint': | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |           $new_constraints[$class] = $this->normalizeCheckInDayConstraints(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |           break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |         default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |           if (isset($this->constraints[$class])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |             $new_constraints[$class] = $this->constraints[$class]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |           } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     if ($constraint_class == NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |       return $new_constraints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |     else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |       return $new_constraints[$constraint_class]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |    * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |   protected function normalizeMinMaxDaysConstraints() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     $new_constraints = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |     $constraints = array_map(function ($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\MinMaxDaysConstraint']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     foreach (array_reverse($constraints) as $constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |       $start_date = $constraint->getStartDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |       $end_date = $constraint->getEndDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |       $split_constraint = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |       if (!empty($new_constraints)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |         foreach ($new_constraints as $new_constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |           $new_start_date = $new_constraint->getStartDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |           $new_end_date = $new_constraint->getEndDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |           if ($constraint->getMinDays() && $new_constraint->getMinDays() || | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |               ($constraint->getMaxDays() && $new_constraint->getMaxDays())) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 114 |  | View Code Duplication |             if ($start_date >= $new_start_date && $start_date <= $new_end_date) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |               $new_end_date_clone = clone($new_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |               $constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             elseif ($end_date >= $new_start_date && $end_date <= $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |               $new_start_date_clone = clone($new_start_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |               $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             elseif ($start_date < $new_start_date && $end_date > $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |               if ($constraint->getEndDate() > $new_start_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 $new_start_date_clone = clone($new_start_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |               if ($split_constraint == NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |                 $split_start_date = clone($new_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |                 $split_start_date->add(new \DateInterval('P1D')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |                 $split_end_date = $end_date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 $split_constraint = new MinMaxDaysConstraint($constraint->getUnits(), $constraint->getMinDays(), $constraint->getMaxDays(), $split_start_date, $split_end_date, $constraint->getCheckinDay()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |               else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |                 $split_start_date = $split_constraint->getStartDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |                 $split_end_date = $split_constraint->getEndDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |                 if ($split_start_date < $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |                   $new_end_date_clone = clone($new_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |                   $split_constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |                 if ($split_end_date < $new_start_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |                   $new_start_date_clone = clone($new_start_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |                   $split_constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |           } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         if ($split_constraint != NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |           $new_constraints[] = $split_constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |       $new_constraints[] = $constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |     foreach ($new_constraints as $i => $constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |       if ($constraint->getStartDate() > $constraint->getEndDate()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         unset($new_constraints[$i]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |     return $new_constraints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |   /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |    * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |    */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |   protected function normalizeCheckInDayConstraints() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |     $new_constraints = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |     $constraints = array_map(function ($object) { return clone $object; }, $this->constraints['Roomify\Bat\Constraint\CheckInDayConstraint']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |     foreach (array_reverse($constraints) as $constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |       $start_date = $constraint->getStartDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |       $end_date = $constraint->getEndDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |       $split_constraint = NULL; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |       if (!empty($new_constraints)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         foreach ($new_constraints as $new_constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |           $new_start_date = $new_constraint->getStartDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |           $new_end_date = $new_constraint->getEndDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 188 |  | View Code Duplication |           if ($constraint->getCheckinDay() && $new_constraint->getCheckinDay()) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             if ($start_date >= $new_start_date && $start_date <= $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |               $new_end_date_clone = clone($new_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |               $constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             elseif ($end_date >= $new_start_date && $end_date <= $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |               $new_start_date_clone = clone($new_start_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |               $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             elseif ($start_date < $new_start_date && $end_date > $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |               if ($constraint->getEndDate() > $new_start_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |                 $new_start_date_clone = clone($new_start_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |                 $constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |               if ($split_constraint == NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |                 $split_start_date = clone($new_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |                 $split_start_date->add(new \DateInterval('P1D')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |                 $split_end_date = $end_date; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |                 $split_constraint = new CheckInDayConstraint($constraint->getUnits(), $constraint->getCheckinDay(), $split_start_date, $split_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |               else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |                 $split_start_date = $split_constraint->getStartDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |                 $split_end_date = $split_constraint->getEndDate(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |                 if ($split_start_date < $new_end_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                   $new_end_date_clone = clone($new_end_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |                   $split_constraint->setStartDate($new_end_date_clone->add(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |                 if ($split_end_date < $new_start_date) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                   $new_start_date_clone = clone($new_start_date); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                   $split_constraint->setEndDate($new_start_date_clone->sub(new \DateInterval('P1D'))); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |               } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |           } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |         if ($split_constraint != NULL) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |           $new_constraints[] = $split_constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |       $new_constraints[] = $constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |     foreach ($new_constraints as $i => $constraint) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |       if ($constraint->getStartDate() > $constraint->getEndDate()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |         unset($new_constraints[$i]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |       } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     return $new_constraints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |   } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |    | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 244 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 245 |  |  |  | 
            
                        
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.