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 preceded 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 public function setRawMimeDirValue($val) 29 { 30 $this->setValue((int) $val); 31 } 32 33 /** 34 * Returns a raw mime-dir representation of the value. 35 * 36 * @return string 37 */ 38 public function getRawMimeDirValue() 39 { 40 return $this->value; 41 } 42 43 /** 44 * Returns the type of value. 45 * 46 * This corresponds to the VALUE= parameter. Every property also has a 47 * 'default' valueType. 48 * 49 * @return string 50 */ 51 public function getValueType() 52 { 53 return 'INTEGER'; 54 } 55 56 /** 57 * Returns the value, in the format it should be encoded for json. 58 * 59 * This method must always return an array. 60 * 61 * @return array 62 */ 63 public function getJsonValue() 64 { 65 return [(int) $this->getValue()]; 66 } 67 68 /** 69 * Hydrate data from a XML subtree, as it would appear in a xCard or xCal 70 * object. 71 * 72 * @param array $value 73 */ 74 public function setXmlValue(array $value) 75 { 76 $value = array_map('intval', $value); 77 parent::setXmlValue($value); 78 } 79} 80