PluginProbe
Import Social Events / 1.8.5
Import Social Events v1.8.5
1.9.1 1.9.0 trunk 1.0.0 1.0.1 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 All 61 releases
import-facebook-events / includes / lib / icalcreator / src / Traits / CLASStrait.php

CLASStrait.php in Import Social Events 1.8.5, at includes/lib/icalcreator/src/Traits/CLASStrait.php

142 lines 4.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * iCalcreator, the PHP class package managing iCal (rfc2445/rfc5445) calendar information.
4 *
5 * copyright (c) 2007-2021 Kjell-Inge Gustafsson, kigkonsult, All rights reserved
6 * Link https://kigkonsult.se
7 * Package iCalcreator
8 * Version 2.30
9 * License Subject matter of licence is the software iCalcreator.
10 * The above copyright, link, package and version notices,
11 * this licence notice and the invariant [rfc5545] PRODID result use
12 * as implemented and invoked in iCalcreator shall be included in
13 * all copies or substantial portions of the iCalcreator.
14 *
15 * iCalcreator is free software: you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License as published
17 * by the Free Software Foundation, either version 3 of the License,
18 * or (at your option) any later version.
19 *
20 * iCalcreator is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public License
26 * along with iCalcreator. If not, see <https://www.gnu.org/licenses/>.
27 *
28 * This file is a part of iCalcreator.
29 */
30
31 namespace Kigkonsult\Icalcreator\Traits;
32
33 use InvalidArgumentException;
34 use Kigkonsult\Icalcreator\Util\ParameterFactory;
35 use Kigkonsult\Icalcreator\Util\StringFactory;
36 use Kigkonsult\Icalcreator\Util\Util;
37
38 use function strtoupper;
39
40 /**
41 * CLASS property functions
42 *
43 * @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se>
44 * @since 2.29.14 2019-09-03
45 */
46 trait CLASStrait
47 {
48 /**
49 * @var array component property CLASS value
50 */
51 protected $class = null;
52
53 /**
54 * @var string
55 * @static
56 */
57 protected static $KLASS = 'class';
58
59 /**
60 * Return formatted output for calendar component property class
61 *
62 * @return string
63 */
64 public function createClass() {
65 if( empty( $this->{self::$KLASS} ))
66 {
67 return null;
68 }
69 if( empty( $this->{self::$KLASS}[Util::$LCvalue] )) {
70 return $this->getConfig( self::ALLOWEMPTY )
71 ? StringFactory::createElement( self::KLASS )
72 : null;
73 }
74 return StringFactory::createElement(
75 self::KLASS,
76 ParameterFactory::createParams( $this->{self::$KLASS}[Util::$LCparams] ),
77 $this->{self::$KLASS}[Util::$LCvalue]
78 );
79 }
80
81 /**
82 * Delete calendar component property class
83 *
84 * @return bool
85 * @since 2.27.1 - 2018-12-15
86 */
87 public function deleteClass( )
88 {
89 $this->{self::$KLASS} = null;
90 return true;
91 }
92
93 /**
94 * Get calendar component property class
95 *
96 * @param bool $inclParam
97 * @return bool|array
98 * @since 2.27.1 - 2018-12-12
99 */
100 public function getClass( $inclParam = false )
101 {
102 if( empty( $this->{self::$KLASS} )) {
103 return false;
104 }
105 return ( $inclParam )
106 ? $this->{self::$KLASS}
107 : $this->{self::$KLASS}[Util::$LCvalue];
108 }
109
110 /**
111 * Set calendar component property class
112 *
113 * @param string $value "PUBLIC" / "PRIVATE" / "CONFIDENTIAL" / iana-token / x-name
114 * @param array $params
115 * @return static
116 * @throws InvalidArgumentException
117 * @since 2.29.14 2019-09-03
118 */
119 public function setClass( $value = null, $params = [] )
120 {
121 $STDVALUES = [
122 self::P_BLIC,
123 self::P_IVATE,
124 self::CONFIDENTIAL
125 ];
126 if( empty( $value )) {
127 $this->assertEmptyValue( $value, self::KLASS );
128 $value = Util::$SP0;
129 $params = [];
130 }
131 elseif( Util::isPropInList( $value, $STDVALUES )) {
132 $value = strtoupper( $value );
133 }
134 Util::assertString( $value, self::KLASS );
135 $this->{self::$KLASS} = [
136 Util::$LCvalue => strtoupper( StringFactory::trimTrailNL((string) $value )),
137 Util::$LCparams => ParameterFactory::setParams( $params ),
138 ];
139 return $this;
140 }
141 }
142