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 / STATUStrait.php

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

154 lines 4.8 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 Kigkonsult\Icalcreator\Vcalendar;
34 use Kigkonsult\Icalcreator\Util\StringFactory;
35 use Kigkonsult\Icalcreator\Util\Util;
36 use Kigkonsult\Icalcreator\Util\ParameterFactory;
37 use InvalidArgumentException;
38
39 use function strtoupper;
40
41 /**
42 * STATUS property functions
43 *
44 * @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se>
45 * @since 2.27.3 2018-12-22
46 */
47 trait STATUStrait
48 {
49 /**
50 * @var array component property STATUS value
51 */
52 protected $status = null;
53
54 /**
55 * Return formatted output for calendar component property status
56 *
57 * @return string
58 */
59 public function createStatus()
60 {
61 if( empty( $this->status )) {
62 return null;
63 }
64 if( empty( $this->status[Util::$LCvalue] )) {
65 return $this->getConfig( self::ALLOWEMPTY )
66 ? StringFactory::createElement( self::STATUS )
67 : null;
68 }
69 return StringFactory::createElement(
70 self::STATUS,
71 ParameterFactory::createParams( $this->status[Util::$LCparams] ),
72 $this->status[Util::$LCvalue]
73 );
74 }
75
76 /**
77 * Delete calendar component property status
78 *
79 * @return bool
80 * @since 2.27.1 - 2018-12-15
81 */
82 public function deleteStatus()
83 {
84 $this->status = null;
85 return true;
86 }
87
88 /**
89 * Get calendar component property status
90 *
91 * @param bool $inclParam
92 * @return bool|array
93 * @since 2.27.1 - 2018-12-12
94 */
95 public function getStatus( $inclParam = false )
96 {
97 if( empty( $this->status )) {
98 return false;
99 }
100 return ( $inclParam ) ? $this->status : $this->status[Util::$LCvalue];
101 }
102
103 /**
104 * Set calendar component property status
105 *
106 * @param string $value
107 * @param array $params
108 * @return static
109 * @throws InvalidArgumentException
110 * @since 2.29.14 2019-09-03
111 */
112 public function setStatus( $value = null, $params = [] )
113 {
114 static $ALLOWED_VEVENT = [
115 self::CONFIRMED,
116 self::CANCELLED,
117 self::TENTATIVE
118 ];
119 static $ALLOWED_VTODO = [
120 self::COMPLETED,
121 self::CANCELLED,
122 self::IN_PROCESS,
123 self::NEEDS_ACTION,
124 ];
125 static $ALLOWED_VJOURNAL = [
126 self::CANCELLED,
127 self::DRAFT,
128 self::F_NAL,
129 ];
130 $value = strtoupper( StringFactory::trimTrailNL( $value ));
131 switch( true ) {
132 case ( empty( $value )) :
133 $this->assertEmptyValue( $value, self::STATUS );
134 $value = Util::$SP0;
135 $params = [];
136 break;
137 case ( Vcalendar::VEVENT == $this->getCompType()) :
138 Util::assertInEnumeration( $value, $ALLOWED_VEVENT, self::STATUS );
139 break;
140 case ( Vcalendar::VTODO == $this->getCompType()) :
141 Util::assertInEnumeration( $value, $ALLOWED_VTODO, self::STATUS );
142 break;
143 case ( Vcalendar::VJOURNAL == $this->getCompType()) :
144 Util::assertInEnumeration( $value, $ALLOWED_VJOURNAL, self::STATUS );
145 break;
146 } // end switch
147 $this->status = [
148 Util::$LCvalue => $value ,
149 Util::$LCparams => ParameterFactory::setParams( $params ),
150 ];
151 return $this;
152 }
153 }
154