1<?php
2
3namespace Sabre\VObject\Property;
4
5use
6    Sabre\VObject\Property;
7
8/**
9 * Boolean property.
10 *
11 * This object represents BOOLEAN values. These are always the case-insenstive
12 * string TRUE or FALSE.
13 *
14 * Automatic conversion to PHP's true and false are done.
15 *
16 * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
17 * @author Evert Pot (http://evertpot.com/)
18 * @license http://sabre.io/license/ Modified BSD License
19 */
20class Boolean extends Property {
21
22    /**
23     * Sets a raw value coming from a mimedir (iCalendar/vCard) file.
24     *
25     * This has been 'unfolded', so only 1 line will be passed. Unescaping is
26     * not yet done, but parameters are not included.
27     *
28     * @param string $val
29     *
30     * @return void
31     */
32    function setRawMimeDirValue($val) {
33
34        $val = strtoupper($val) === 'TRUE' ? true : false;
35        $this->setValue($val);
36
37    }
38
39    /**
40     * Returns a raw mime-dir representation of the value.
41     *
42     * @return string
43     */
44    function getRawMimeDirValue() {
45
46        return $this->value ? 'TRUE' : 'FALSE';
47
48    }
49
50    /**
51     * Returns the type of value.
52     *
53     * This corresponds to the VALUE= parameter. Every property also has a
54     * 'default' valueType.
55     *
56     * @return string
57     */
58    function getValueType() {
59
60        return 'BOOLEAN';
61
62    }
63
64    /**
65     * Hydrate data from a XML subtree, as it would appear in a xCard or xCal
66     * object.
67     *
68     * @param array $value
69     *
70     * @return void
71     */
72    function setXmlValue(array $value) {
73
74        $value = array_map(
75            function($value) {
76                return 'true' === $value;
77            },
78            $value
79        );
80        parent::setXmlValue($value);
81
82    }
83
84}
85