public function setValidityPeriod(\DateInterval $validityPeriod = null): self
    {
        if (null !== $validityPeriod &&
            ($validityPeriod->i < ValidityPeriods::MIN || $validityPeriod->i > ValidityPeriods::MAX)
        ) {
            throw new InvalidValidityPeriodException();
        }

        $this->validityPeriod = $validityPeriod;

        return $this;
    }
public function setValidityPeriod(\DateInterval $validityPeriod = null): self
    {
        if (null !== $validityPeriod &&
            ($validityPeriod->i < ValidityPeriods::MIN || $validityPeriod->i > ValidityPeriods::MAX)
        ) {
            throw new InvalidValidityPeriodException();
        }

        $this->validityPeriod = $validityPeriod;

        return $this;
    }
public function setValidityPeriod ( \ DateInterval $ validityPeriod = null ) : self { if ( null !== $ validityPeriod && ( $ validityPeriod -> i < ValidityPeriods :: MIN || $ validityPeriod -> i > ValidityPeriods :: MAX ) ) { throw new InvalidValidityPeriodException ( ) ; } $ this -> validityPeriod = $ validityPeriod ; return $ this ; }
Sets the validity period.

@param \DateInterval|null $validityPeriod

@return $this

@throws InvalidValidityPeriodException
Sets the validity period .