League\Period\Period::__construct PHP Method

__construct() public method

Create a new instance.
public __construct ( DateTimeInterfac\DateTimeInterface | string $startDate, DateTimeInterfac\DateTimeInterface | string $endDate )
$startDate DateTimeInterfac\DateTimeInterface | string starting date point
$endDate DateTimeInterfac\DateTimeInterface | string ending date point
    public function __construct($startDate, $endDate)
    {
        $startDate = static::filterDatePoint($startDate);
        $endDate = static::filterDatePoint($endDate);
        if ($startDate > $endDate) {
            throw new LogicException('The ending datepoint must be greater or equal to the starting datepoint');
        }
        $this->startDate = $startDate;
        $this->endDate = $endDate;
    }

Usage Example

Beispiel #1
0
 public function __construct(Season\Name $name, Period $period)
 {
     if ($period === null) {
         throw new \InvalidArgumentException("de periode moet gezet zijn", E_ERROR);
     }
     parent::__construct($period->getStartDate(), $period->getEndDate());
     if ($name === null) {
         throw new \InvalidArgumentException("de naam moet gezet zijn", E_ERROR);
     }
     $this->m_name = $name;
 }