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    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     * @param array $value
43     */
44    public function setJsonValue(array $value)
45    {
46        $value = array_map(
47            function ($value) {
48                return str_replace(':', '', $value);
49            },
50            $value
51        );
52        parent::setJsonValue($value);
53    }
54
55    /**
56     * Returns the value, in the format it should be encoded for JSON.
57     *
58     * This method must always return an array.
59     *
60     * @return array
61     */
62    public function getJsonValue()
63    {
64        return array_map(
65            function ($value) {
66                return substr($value, 0, -2).':'.
67                       substr($value, -2);
68            },
69            parent::getJsonValue()
70        );
71    }
72}
73