. * * This file is a part of iCalcreator. */ namespace Kigkonsult\Icalcreator\Traits; use Kigkonsult\Icalcreator\Util\Util; use function is_numeric; /** * PRIORITY property functions * * @author Kjell-Inge Gustafsson, kigkonsult * @since 2.22.23 - 2017-02-02 */ trait PRIORITYtrait { /** * @var array component property PRIORITY value * @access protected */ protected $priority = null; /** * Return formatted output for calendar component property priority * * @return string */ public function createPriority() { if( ! isset( $this->priority ) || ( empty( $this->priority ) && ! is_numeric( $this->priority ))) { return null; } if( ! isset( $this->priority[Util::$LCvalue] ) || ( empty( $this->priority[Util::$LCvalue] ) && ! is_numeric( $this->priority[Util::$LCvalue] ))) { return ( $this->getConfig( Util::$ALLOWEMPTY )) ? Util::createElement( Util::$PRIORITY ) : null; } return Util::createElement( Util::$PRIORITY, Util::createParams( $this->priority[Util::$LCparams] ), $this->priority[Util::$LCvalue] ); } /** * Set calendar component property priority * * @param int $value * @param array $params * @return bool */ public function setPriority( $value, $params = null ) { if( empty( $value ) && ! is_numeric( $value )) { if( $this->getConfig( Util::$ALLOWEMPTY )) { $value = Util::$SP0; } else { return false; } } $this->priority = [ Util::$LCvalue => $value, Util::$LCparams => Util::setParams( $params ), ]; return true; } }