PluginProbe
Import Social Events / 1.8.7
Import Social Events v1.8.7
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 / LAST_MODIFIEDtrait.php

LAST_MODIFIEDtrait.php in Import Social Events 1.8.7, at includes/lib/icalcreator/src/Traits/LAST_MODIFIEDtrait.php

132 lines 4.1 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 * LAST-MODIFIED property functions
47 *
48 * @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se>
49 * @since 2.29.16 2020-01-24
50 */
51 trait LAST_MODIFIEDtrait
52 {
53 /**
54 * @var array component property LAST-MODIFIED value
55 */
56 protected $lastmodified = null;
57
58 /**
59 * Return formatted output for calendar component property last-modified
60 *
61 * @return string
62 * @throws Exception
63 * @throws InvalidArgumentException
64 * @since 2.29.9 2019-08-05
65 */
66 public function createLastmodified()
67 {
68 if( empty( $this->lastmodified )) {
69 return null;
70 }
71 return StringFactory::createElement(
72 self::LAST_MODIFIED,
73 ParameterFactory::createParams( $this->lastmodified[Util::$LCparams] ),
74 DateTimeFactory::dateTime2Str( $this->lastmodified[Util::$LCvalue] )
75 );
76 }
77
78 /**
79 * Delete calendar component property lastmodified
80 *
81 * @return bool
82 * @since 2.27.1 - 2018-12-15
83 */
84 public function deleteLastmodified()
85 {
86 $this->lastmodified = null;
87 return true;
88 }
89
90 /**
91 * Return calendar component property last-modified
92 *
93 * @param bool $inclParam
94 * @return bool|DateTime|array
95 * @since 2.29.9 2019-08-05
96 */
97 public function getLastmodified( $inclParam = false )
98 {
99 if( empty( $this->lastmodified )) {
100 return false;
101 }
102 return ( $inclParam )
103 ? $this->lastmodified
104 : $this->lastmodified[Util::$LCvalue];
105 }
106
107 /**
108 * Set calendar component property last-modified
109 *
110 * @param string|DateTimeInterface $value
111 * @param array $params
112 * @return static
113 * @throws Exception
114 * @throws InvalidArgumentException
115 * @since 2.29.16 2020-01-24
116 */
117 public function setLastmodified( $value = null, $params = [] )
118 {
119 if( empty( $value )) {
120 $this->lastmodified = [
121 Util::$LCvalue => DateTimeFactory::factory( null, self::UTC ),
122 Util::$LCparams => [],
123 ];
124 return $this;
125 }
126 $params = array_change_key_case( $params, CASE_UPPER );
127 $params[Vcalendar::VALUE] = Vcalendar::DATE_TIME;
128 $this->lastmodified = DateTimeFactory::setDate( $value, $params, true ); // $forceUTC
129 return $this;
130 }
131 }
132