1<?php
2
3namespace 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 */
14class 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|null
21     */
22    public $delimiter = null;
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    function getValueType() {
33
34        return 'UTC-OFFSET';
35
36    }
37
38    /**
39     * Sets the JSON value, as it would appear in a jCard or jCal object.
40     *
41     * The value must always be an array.
42     *
43     * @param array $value
44     *
45     * @return void
46     */
47    function setJsonValue(array $value) {
48
49        $value = array_map(
50            function($value) {
51                return str_replace(':', '', $value);
52            },
53            $value
54        );
55        parent::setJsonValue($value);
56
57    }
58
59    /**
60     * Returns the value, in the format it should be encoded for JSON.
61     *
62     * This method must always return an array.
63     *
64     * @return array
65     */
66    function getJsonValue() {
67
68        return array_map(
69            function($value) {
70                return substr($value, 0, -2) . ':' .
71                       substr($value, -2);
72            },
73            parent::getJsonValue()
74        );
75
76    }
77}
78