Esempio n. 1
0
 /**
  * Converts from string to signed integer. The string can contains the "px" unit.
  * 
  * The minimum and maximum value depends on the system:
  * <ul>
  * <li>32 bit systems have a range of -2147483648 to 2147483647 and</li>
  * <li>32 bit systems have a range of -9223372036854775807 to 9223372036854775807.</li>
  * </ul>
  * 
  * Empty string throws an exception.
  * @param string|boolean $value A string or boolean <i>true</i>
  * @return int
  * @throws UserError When value is not a signed integer.
  */
 public function parse($value)
 {
     // remove the px unit
     if (is_string($value)) {
         $value = str_ireplace(array('px', 'p', 'pt', 'pixel'), '', $value);
     }
     return parent::parse($value);
 }
Esempio n. 2
0
 public function getType($object)
 {
     $type = \strtolower(\gettype($object));
     if (is_int($type)) {
         $int = Integer::parse($object);
         //If an integer type was not enough to store the value
         //let it fall through to string type
         if ($int !== null) {
             return $int;
         }
     }
     if (\is_float($object)) {
         //Prefer decimal over floating point
         return Decimal::parse($object);
     }
     if (\is_bool($object)) {
         return Boolean::parse($object);
     }
     return String::parse($object);
 }