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-insensitive 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 public function setRawMimeDirValue($val) 31 { 32 $val = 'TRUE' === strtoupper($val) ? true : false; 33 $this->setValue($val); 34 } 35 36 /** 37 * Returns a raw mime-dir representation of the value. 38 * 39 * @return string 40 */ 41 public function getRawMimeDirValue() 42 { 43 return $this->value ? 'TRUE' : 'FALSE'; 44 } 45 46 /** 47 * Returns the type of value. 48 * 49 * This corresponds to the VALUE= parameter. Every property also has a 50 * 'default' valueType. 51 * 52 * @return string 53 */ 54 public function getValueType() 55 { 56 return 'BOOLEAN'; 57 } 58 59 /** 60 * Hydrate data from a XML subtree, as it would appear in a xCard or xCal 61 * object. 62 * 63 * @param array $value 64 */ 65 public function setXmlValue(array $value) 66 { 67 $value = array_map( 68 function ($value) { 69 return 'true' === $value; 70 }, 71 $value 72 ); 73 parent::setXmlValue($value); 74 } 75} 76