1<?php
2
3namespace Sabre\VObject\Property\ICalendar;
4
5use
6    Sabre\VObject\Property\Text;
7
8/**
9 * CalAddress property.
10 *
11 * This object encodes CAL-ADDRESS values, as defined in rfc5545
12 *
13 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
14 * @author Evert Pot (http://evertpot.com/)
15 * @license http://sabre.io/license/ Modified BSD License
16 */
17class CalAddress extends Text
18{
19    /**
20     * In case this is a multi-value property. This string will be used as a
21     * delimiter.
22     *
23     * @var string|null
24     */
25    public $delimiter = null;
26
27    /**
28     * Returns the type of value.
29     *
30     * This corresponds to the VALUE= parameter. Every property also has a
31     * 'default' valueType.
32     *
33     * @return string
34     */
35    public function getValueType()
36    {
37        return 'CAL-ADDRESS';
38    }
39
40    /**
41     * This returns a normalized form of the value.
42     *
43     * This is primarily used right now to turn mixed-cased schemes in user
44     * uris to lower-case.
45     *
46     * Evolution in particular tends to encode mailto: as MAILTO:.
47     *
48     * @return string
49     */
50    public function getNormalizedValue()
51    {
52        $input = $this->getValue();
53        if (!strpos($input, ':')) {
54            return $input;
55        }
56        list($schema, $everythingElse) = explode(':', $input, 2);
57
58        return strtolower($schema).':'.$everythingElse;
59    }
60}
61