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