ICalendar
1 year ago
VCard
1 year ago
Binary.php
1 year ago
Boolean.php
1 year ago
FlatText.php
1 year ago
FloatValue.php
1 year ago
IntegerValue.php
1 year ago
Text.php
1 year ago
Time.php
1 year ago
Unknown.php
1 year ago
Uri.php
1 year ago
UtcOffset.php
1 year ago
UtcOffset.php
71 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Sabre\VObject\Property; |
| 4 | |
| 5 | /** |
| 6 | * UtcOffset property. |
| 7 | * |
| 8 | * This object encodes UTC-OFFSET values. |
| 9 | * |
| 10 | * @copyright Copyright (C) fruux GmbH (https://fruux.com/) |
| 11 | * @author Evert Pot (http://evertpot.com/) |
| 12 | * @license http://sabre.io/license/ Modified BSD License |
| 13 | */ |
| 14 | class UtcOffset extends Text |
| 15 | { |
| 16 | /** |
| 17 | * In case this is a multi-value property. This string will be used as a |
| 18 | * delimiter. |
| 19 | * |
| 20 | * @var string |
| 21 | */ |
| 22 | public $delimiter = ''; |
| 23 | |
| 24 | /** |
| 25 | * Returns the type of value. |
| 26 | * |
| 27 | * This corresponds to the VALUE= parameter. Every property also has a |
| 28 | * 'default' valueType. |
| 29 | * |
| 30 | * @return string |
| 31 | */ |
| 32 | public function getValueType() |
| 33 | { |
| 34 | return 'UTC-OFFSET'; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Sets the JSON value, as it would appear in a jCard or jCal object. |
| 39 | * |
| 40 | * The value must always be an array. |
| 41 | */ |
| 42 | public function setJsonValue(array $value) |
| 43 | { |
| 44 | $value = array_map( |
| 45 | function ($value) { |
| 46 | return str_replace(':', '', $value); |
| 47 | }, |
| 48 | $value |
| 49 | ); |
| 50 | parent::setJsonValue($value); |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns the value, in the format it should be encoded for JSON. |
| 55 | * |
| 56 | * This method must always return an array. |
| 57 | * |
| 58 | * @return array |
| 59 | */ |
| 60 | public function getJsonValue() |
| 61 | { |
| 62 | return array_map( |
| 63 | function ($value) { |
| 64 | return substr($value, 0, -2).':'. |
| 65 | substr($value, -2); |
| 66 | }, |
| 67 | parent::getJsonValue() |
| 68 | ); |
| 69 | } |
| 70 | } |
| 71 |