Entity/Person.php
public function checkAccompanyingPeriodsAreNotCollapsing()
    {
        $periods = $this->getAccompanyingPeriodsOrdered();
        $periodsNbr = sizeof($periods);
        $i = 0;
        
        while($i < $periodsNbr - 1) {
            $periodI = $periods[$i];
            $periodAfterI = $periods[$i + 1];
            
            if($periodI->isOpen()) {                
                return array(
                    'result' => self::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD,
                    'dateOpening' => $periodAfterI->getOpeningDate(),
                    'dateClosing' => $periodAfterI->getClosingDate(),
                    'date' => $periodI->getOpeningDate()
                );
            } elseif ($periodI->getClosingDate() >= $periodAfterI->getOpeningDate()) {
                return array(
                    'result' => self::ERROR_PERIODS_ARE_COLLAPSING,
                    'dateOpening' => $periodI->getOpeningDate(),
                    
                    'dateClosing' => $periodI->getClosingDate(),
                    'date' => $periodAfterI->getOpeningDate()
                );
            }
            $i++;
        }
        
        return true;
    }
public function checkAccompanyingPeriodsAreNotCollapsing()
    {
        $periods = $this->getAccompanyingPeriodsOrdered();
        $periodsNbr = sizeof($periods);
        $i = 0;
        
        while($i < $periodsNbr - 1) {
            $periodI = $periods[$i];
            $periodAfterI = $periods[$i + 1];
            
            if($periodI->isOpen()) {                
                return array(
                    'result' => self::ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD,
                    'dateOpening' => $periodAfterI->getOpeningDate(),
                    'dateClosing' => $periodAfterI->getClosingDate(),
                    'date' => $periodI->getOpeningDate()
                );
            } elseif ($periodI->getClosingDate() >= $periodAfterI->getOpeningDate()) {
                return array(
                    'result' => self::ERROR_PERIODS_ARE_COLLAPSING,
                    'dateOpening' => $periodI->getOpeningDate(),
                    
                    'dateClosing' => $periodI->getClosingDate(),
                    'date' => $periodAfterI->getOpeningDate()
                );
            }
            $i++;
        }
        
        return true;
    }
public function checkAccompanyingPeriodsAreNotCollapsing ( ) { $ periods = $ this -> getAccompanyingPeriodsOrdered ( ) ; $ periodsNbr = sizeof ( $ periods ) ; $ i = 0 ; while ( $ i < $ periodsNbr - 1 ) { $ periodI = $ periods [ $ i ] ; $ periodAfterI = $ periods [ $ i + 1 ] ; if ( $ periodI -> isOpen ( ) ) { return array ( 'result' => self :: ERROR_ADDIND_PERIOD_AFTER_AN_OPEN_PERIOD , 'dateOpening' => $ periodAfterI -> getOpeningDate ( ) , 'dateClosing' => $ periodAfterI -> getClosingDate ( ) , 'date' => $ periodI -> getOpeningDate ( ) ) ; } elseif ( $ periodI -> getClosingDate ( ) >= $ periodAfterI -> getOpeningDate ( ) ) { return array ( 'result' => self :: ERROR_PERIODS_ARE_COLLAPSING , 'dateOpening' => $ periodI -> getOpeningDate ( ) , 'dateClosing' => $ periodI -> getClosingDate ( ) , 'date' => $ periodAfterI -> getOpeningDate ( ) ) ; } $ i ++ ; } return true ; }
Function used for validation that check if the accompanying periods of
the person are not collapsing (i.e. have not shared days) or having
a period after an open period.

@return true | array True if the accompanying periods are not collapsing,
an array with data for displaying the error
Function used for validation that check if the accompanying periods of the person are not collapsing ( i . e . have not shared days ) or having a period after an open period .