示例#1
0
 /**
  * Determines if the value is the correct type to assign to a property.
  *
  * @param mixed $name The value to check the type of.
  * @throws InvalidPropertyTypeException If the value is the wrong type for the property.
  */
 private function ensurePropertyType($value)
 {
     $actualType = gettype($value);
     if ('object' === $actualType) {
         $actualType = get_class($value);
     }
     $valid = explode('|', $this->expectedType);
     $isValid = false;
     foreach ($valid as $check) {
         if (\DTS\eBaySDK\checkPropertyType($check)) {
             if ($check === $actualType) {
                 return;
             }
             $isValid = false;
         } else {
             $isValid = true;
         }
     }
     if (!$isValid) {
         throw new Exceptions\InvalidPropertyTypeException($this->property, $this->expectedType, $actualType);
     }
 }
示例#2
0
 /**
  * Determines if the value is the correct type to assign to a property.
  *
  * @param string $class The name of the class that we are checking for.
  * @param string $name The property name.
  * @param mixed $name The value to check the type of.
  * @throws InvalidPropertyTypeException If the value is the wrong type for the property.
  */
 private static function ensurePropertyType($class, $name, $value)
 {
     $info = self::propertyInfo($class, $name);
     $expectedType = $info['type'];
     if (\DTS\eBaySDK\checkPropertyType($expectedType)) {
         $actualType = self::getActualType($value);
         if ($expectedType !== $actualType && 'array' !== $actualType) {
             throw new Exceptions\InvalidPropertyTypeException($name, $expectedType, $actualType);
         }
     }
 }
示例#3
0
 /**
  * Determines if the value is the correct type to assign to a property.
  *
  * @param string $class The name of the class that we are checking for.
  * @param string $name The property name.
  * @param mixed $name The value to check the type of.
  * @throws InvalidPropertyTypeException If the value is the wrong type for the property.
  */
 private static function ensurePropertyType($class, $name, $value)
 {
     $isValid = false;
     $info = self::propertyInfo($class, $name);
     $actualType = self::getActualType($value);
     $valid = explode('|', $info['type']);
     foreach ($valid as $check) {
         if (\DTS\eBaySDK\checkPropertyType($check)) {
             if ($check === $actualType || 'array' === $actualType) {
                 return;
             }
             $isValid = false;
         } else {
             $isValid = true;
         }
     }
     if (!$isValid) {
         $expectedType = $info['type'];
         throw new Exceptions\InvalidPropertyTypeException($name, $expectedType, $actualType);
     }
 }
 /**
  * Determines if the value is the correct type to assign to a property.
  *
  * @param mixed $name The value to check the type of.
  * @throws InvalidPropertyTypeException If the value is the wrong type for the property.
  */
 private function ensurePropertyType($value)
 {
     if (\DTS\eBaySDK\checkPropertyType($this->expectedType)) {
         $actualType = gettype($value);
         if ('object' === $actualType) {
             $actualType = get_class($value);
         }
         if ($this->expectedType !== $actualType) {
             throw new Exceptions\InvalidPropertyTypeException($this->property, $this->expectedType, $actualType);
         }
     }
 }