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

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

130 lines 4.0 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 DateTime;
34 use DateTimeInterface;
35 use Exception;
36 use InvalidArgumentException;
37 use Kigkonsult\Icalcreator\Util\DateTimeFactory;
38 use Kigkonsult\Icalcreator\Util\ParameterFactory;
39 use Kigkonsult\Icalcreator\Util\StringFactory;
40 use Kigkonsult\Icalcreator\Util\Util;
41 use Kigkonsult\Icalcreator\Vcalendar;
42
43 use function array_change_key_case;
44
45 /**
46 * CREATED property functions
47 *
48 * @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se>
49 * @since 2.29.16 2020-01-24
50 */
51 trait CREATEDtrait
52 {
53 /**
54 * @var array component property CREATED value
55 */
56 protected $created = null;
57
58 /**
59 * Return formatted output for calendar component property created
60 *
61 * @return string
62 * @throws Exception
63 * @throws InvalidArgumentException
64 * @since 2.29.1 2019-06-22
65 */
66 public function createCreated()
67 {
68 if( empty( $this->created )) {
69 return null;
70 }
71 return StringFactory::createElement(
72 self::CREATED,
73 ParameterFactory::createParams( $this->created[Util::$LCparams] ),
74 DateTimeFactory::dateTime2Str( $this->created[Util::$LCvalue] )
75 );
76 }
77
78 /**
79 * Delete calendar component property created
80 *
81 * @return bool
82 * @since 2.27.1 - 2018-12-15
83 */
84 public function deleteCreated()
85 {
86 $this->created = null;
87 return true;
88 }
89
90 /**
91 * Return calendar component property created
92 *
93 * @param bool $inclParam
94 * @return bool|DateTime|array
95 * @since 2.27.14 - 2019-01-27
96 */
97 public function getCreated( $inclParam = false )
98 {
99 if( empty( $this->created )) {
100 return false;
101 }
102 return ( $inclParam ) ? $this->created : $this->created[Util::$LCvalue];
103 }
104
105 /**
106 * Set calendar component property created
107 *
108 * @param string|DateTimeInterface $value
109 * @param mixed $params
110 * @return static
111 * @throws Exception
112 * @throws InvalidArgumentException
113 * @since 2.29.16 2020-01-24
114 */
115 public function setCreated( $value = null, $params = [] )
116 {
117 if( empty( $value )) {
118 $this->created = [
119 Util::$LCvalue => DateTimeFactory::factory( null, self::UTC ),
120 Util::$LCparams => [],
121 ];
122 return $this;
123 }
124 $params = array_change_key_case( $params, CASE_UPPER );
125 $params[Vcalendar::VALUE] = Vcalendar::DATE_TIME;
126 $this->created = DateTimeFactory::setDate( $value, $params, true ); // $forceUTC
127 return $this;
128 }
129 }
130