* @author Christian Kruse * @copyright Copyright © 2018 Teclib * @package plist * @license MIT * @link https://github.com/TECLIB/CFPropertyList/ * @link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists * ------------------------------------------------------------------------------ */ namespace CFPropertyList; use \DOMDocument; use \Iterator; use \ArrayAccess; /** * Number Type of CFPropertyList * {@link http://developer.apple.com/documentation/Darwin/Reference/ManPages/man5/plist.5.html Property Lists} */ class CFNumber extends CFType { /** * Get XML-Node. * Returns <real> if $value is a float, <integer> if $value is an integer. * @param DOMDocument $doc DOMDocument to create DOMNode in * @param string $nodeName For compatibility reasons; just ignore it * @return DOMNode <real> or <integer>-Element */ public function toXML(DOMDocument $doc, $nodeName = "") { $ret = 'real'; if (intval($this->value) == $this->value && !is_float($this->value) && strpos($this->value, '.') === false) { $this->value = intval($this->value); $ret = 'integer'; } return parent::toXML($doc, $ret); } /** * convert value to binary representation * @param CFBinaryPropertyList The binary property list object * @return The offset in the object table */ public function toBinary(CFBinaryPropertyList &$bplist) { return $bplist->numToBinary($this->value); } }