| 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.2 |
| 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\Util\HttpFactory; |
| 34 |
use Kigkonsult\Icalcreator\Util\ParameterFactory; |
| 35 |
use Kigkonsult\Icalcreator\Util\StringFactory; |
| 36 |
use Kigkonsult\Icalcreator\Util\Util; |
| 37 |
use InvalidArgumentException; |
| 38 |
|
| 39 |
/** |
| 40 |
* URL property functions |
| 41 |
* |
| 42 |
* @author Kjell-Inge Gustafsson, kigkonsult <ical@kigkonsult.se> |
| 43 |
* @since 2.30.2 - 2021-02-04 |
| 44 |
*/ |
| 45 |
trait URLtrait |
| 46 |
{ |
| 47 |
/** |
| 48 |
* @var array component property URL value |
| 49 |
* @access protected |
| 50 |
*/ |
| 51 |
protected $url = null; |
| 52 |
|
| 53 |
/** |
| 54 |
* Return formatted output for calendar component property url |
| 55 |
* |
| 56 |
* @return string |
| 57 |
*/ |
| 58 |
public function createUrl() |
| 59 |
{ |
| 60 |
if( empty( $this->url )) { |
| 61 |
return null; |
| 62 |
} |
| 63 |
if( empty( $this->url[Util::$LCvalue] )) { |
| 64 |
return $this->getConfig( self::ALLOWEMPTY ) |
| 65 |
? StringFactory::createElement( self::URL ) |
| 66 |
: null; |
| 67 |
} |
| 68 |
return StringFactory::createElement( |
| 69 |
self::URL, |
| 70 |
ParameterFactory::createParams( $this->url[Util::$LCparams] ), |
| 71 |
$this->url[Util::$LCvalue] |
| 72 |
); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Delete calendar component property url |
| 77 |
* |
| 78 |
* @return bool |
| 79 |
* @since 2.27.1 - 2018-12-15 |
| 80 |
*/ |
| 81 |
public function deleteUrl() |
| 82 |
{ |
| 83 |
$this->url = null; |
| 84 |
return true; |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Get calendar component property url |
| 89 |
* |
| 90 |
* @param bool $inclParam |
| 91 |
* @return bool|array |
| 92 |
* @since 2.27.1 - 2018-12-12 |
| 93 |
*/ |
| 94 |
public function getUrl( $inclParam = false ) |
| 95 |
{ |
| 96 |
if( empty( $this->url )) { |
| 97 |
return false; |
| 98 |
} |
| 99 |
return ( $inclParam ) ? $this->url : $this->url[Util::$LCvalue]; |
| 100 |
} |
| 101 |
|
| 102 |
/** |
| 103 |
* Set calendar component property url |
| 104 |
* |
| 105 |
* @param string $value |
| 106 |
* @param array $params |
| 107 |
* @return static |
| 108 |
* @throws InvalidArgumentException |
| 109 |
* @since 2.30.2 - 2021-02-04 |
| 110 |
*/ |
| 111 |
public function setUrl( $value = null, $params = [] ) |
| 112 |
{ |
| 113 |
if( empty( $value )) { |
| 114 |
$this->assertEmptyValue( $value, self::URL ); |
| 115 |
$this->url = [ |
| 116 |
Util::$LCvalue => Util::$SP0, |
| 117 |
Util::$LCparams => [], |
| 118 |
]; |
| 119 |
return $this; |
| 120 |
} |
| 121 |
HttpFactory::urlSet( $this->url, $value, $params ); |
| 122 |
return $this; |
| 123 |
} |
| 124 |
} |
| 125 |
|