Get self with validity period.

@param AttCertValidityPeriod $validity
@return self
502037
public function withValidity(AttCertValidityPeriod $validity): self
    {
        $obj = clone $this;
        $obj->_attrCertValidityPeriod = $validity;
        return $obj;
    }
1046991
public function register(Type $type): self
    {
        $this->types[$type->name] = $type;

        return $this;
    }
994779
public function getEpcValidUntil($format = 'Y-m-d')
    {
        if ($this->epcValidUntil instanceof \DateTime && $format !== null) {
            return $this->epcValidUntil->format($format);
        }

        return $this->epcValidUntil;
    }
505916
public function withDateAtStartOfMonth() : self
    {
        $instance = $this->withTimeAtMidnight();
        
        $instance->date->setDate($instance->year(), $instance->month(), 1);
        
        return $instance;
    }
982408
protected function getValidator()
    {
        if ($form = $this->owner->getForm()) {
            
            if (($validator = $form->getValidator()) && $validator instanceof Validator) {
                return $validator;
            }
            
        }
    }
781491
public function withIndefiniteLength(bool $indefinite = true): self
    {
        $obj = clone $this;
        $obj->_indefiniteLength = $indefinite;
        return $obj;
    }
390465
public static function createFromDateString($duration): self
    {
        $duration = parent::createFromDateString($duration);
        if (false === $duration) {
            return $duration;
        }

        $new = new self('PT0S');
        foreach ($duration as $name => $value) {
            $new->$name = $value;
        }

        return $new;
    }
176409
public Subscription limitValidity( Subscription subscription, Interval.Period newValidity ) {
    ParameterMap<String, String> params = new ParameterMap<String, String>();
    ValidationUtils.validatesIntervalPeriod( newValidity );
    params.add( "period_of_validity", newValidity.toString() );
    return RestfulUtils.update( SubscriptionService.PATH, subscription, params, false, Subscription.class, super.httpClient );
  }
327055
protected function validate()
    {
        $valid = parent::validate();
        foreach ($this as $child) {
            $valid = $child->validate() && $valid;
        }
        return $valid;
    }
675349
@Override
	public Date whenToValidate(Notify type, Date lastValidated) {
		switch(type) {
			case Approval:
			case PasswordExpiration:
				return null;
			default:
				GregorianCalendar gc = new GregorianCalendar();
				gc.setTime(lastValidated);
				gc.add(GregorianCalendar.MONTH, 6);  // 6 month policy
				return gc.getTime();
		}
	}
445673
private function _validateTime()
    {
        $t = $this->_config->evaluationTime();
        $validity = $this->_ac->acinfo()->validityPeriod();
        if ($validity->notBeforeTime()->diff($t)->invert) {
            throw new ACValidationException("Validity period has not started.");
        }
        if ($t->diff($validity->notAfterTime())->invert) {
            throw new ACValidationException("Attribute certificate has expired.");
        }
    }
922094
public function setExpiration(int $timestamp): self
    {
        if (!$this->validate->expiration($timestamp)) {
            throw new ValidateException('Expiration claim has expired.', 4);
        }

        $this->payload['exp'] = $timestamp;

        return $this;
    }
274950
public function setType(?string $type): self
    {
        if (!$this->isValidType($type)) {
            throw new \InvalidArgumentException(\sprintf(
                "Invalid type '%s'. Must be either NULL, one of %s, or a fully qualified class name or interface",
                $type,
                \implode(', ', $this->getValidTypes())
            ));
        }

        $this->type = $type;

        return $this;
    }
1239719
public function withIntervalInMonths($intervalInMonths)
    {
        $this->validateInterval($intervalInMonths);
        $this->interval = $intervalInMonths;
        $this->intervalUnit = IntervalUnit::MONTH;

        return $this;
    }
1129903
public function setValid(string $valid)
    {
        if ($this->valid) {
            $this->valid .= '|'.$valid;
        } else {
            $this->valid = $valid;
        }

        return $this;
    }
302293
public function cacheInvalidate( $type = self::ALL )
    {
        switch( $type ) {
            case self::PERSISTED:
                $return = count( $this->instancesPersisted );
                $this->instancesPersisted = array();
                return $return;
            case self::UNPERSISTED:
                $return = count( $this->instancesUnpersisted );
                $this->instancesUnpersisted = array();
                return $return;
            case self::ALL:
                $return = count( $this->instancesPersisted ) + count( $this->instancesUnpersisted );
                $this->instancesPersisted = array();
                $this->instancesUnpersisted = array();
                return $return;
        }
        throw new \InvalidArgumentException("Bad source `{$source}` passed to " . __FUNCTION__);
    }
841403
public function setValidation($validation)
    {
        /*If a single validation class is provided, an array is created in order to reuse the same logic.*/
        if (!is_array($validation)) {
            $validation = array($validation);
        }

        foreach ($validation as $object) {
            /*Ensures $object contains a existing concrete validation class.*/
            if ($object instanceof Validation) {
                $this->validation[] = $object;

                if ($object instanceof Validation\Required) {
                    $this->attributes["required"] = "";
                }
            }
        }
    }