. * * This file is a part of iCalcreator. */ namespace Kigkonsult\Icalcreator\Traits; use Kigkonsult\Icalcreator\Util\Util; /** * UID property functions * * @author Kjell-Inge Gustafsson, kigkonsult * @since 2.23.20 - 2017-02-17 */ trait UIDtrait { /** * @var array component property UID value * @access protected */ protected $uid = null; /** * Return formatted output for calendar component property uid * * If uid is missing, uid is created * * @return string */ public function createUid() { if( empty( $this->uid )) { $this->uid = Util::makeUid( $this->getConfig( Util::$UNIQUE_ID )); } return Util::createElement( Util::$UID, Util::createParams( $this->uid[Util::$LCparams] ), $this->uid[Util::$LCvalue] ); } /** * Set calendar component property uid * * @param string $value * @param array $params * @return bool */ public function setUid( $value, $params = null ) { if( empty( $value ) && ( Util::$ZERO != $value )) { return false; } // no allowEmpty check here !!!! $this->uid = [ Util::$LCvalue => Util::trimTrailNL( $value ), Util::$LCparams => Util::setParams( $params ), ]; return true; } }