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