isBasicType() public method

Tells whether property type is basic type (boolean|integer|float|string|array)
public isBasicType ( ) : boolean
return boolean
Beispiel #1
0
 private function getType(Property $property)
 {
     $type = NULL;
     if ($property->isBasicType()) {
         $type = $property->getType();
         if ($type == 'string') {
             if (!$property->hasCustomFlag('size')) {
                 $type = 'text';
             }
         }
         /* if ($property->containsEnumeration()) {
         	  $type = 'enum';
         	  } */
     } else {
         // Objects
         $class = new ReflectionClass($property->getType());
         $class = $class->newInstance();
         if ($class instanceof DateTime) {
             if ($property->hasCustomFlag('format')) {
                 $type = $property->getCustomFlagValue('format');
             } else {
                 $type = 'datetime';
             }
         }
     }
     return $type;
 }
Beispiel #2
0
 private function replacePlaceholder(Property $property)
 {
     $type = $property->getType();
     if ($property->isBasicType()) {
         if (array_key_exists($type, self::$placeholders)) {
             return self::$placeholders[$type];
         } else {
             return self::$defaultPlaceholder;
         }
     } else {
         if ($type === 'DateTime' || is_subclass_of($type, 'DateTime')) {
             if ($property->hasCustomFlag(self::$typeFlagName) && preg_match('#^(DATE|Date|date)$#', $property->getCustomFlagValue(self::$typeFlagName))) {
                 return self::$placeholders['Date'];
             } else {
                 return self::$placeholders['DateTime'];
             }
         } else {
             return self::$defaultPlaceholder;
         }
     }
 }
 private function getType(Property $property)
 {
     $type = null;
     if ($property->isBasicType()) {
         $type = $property->getType();
         if ($type == 'string') {
             if ($property->hasCustomFlag('type')) {
                 $type = $property->getCustomFlagValue('type');
             } else {
                 if (!$property->hasCustomFlag('size') || $property->getCustomFlagValue('size') >= 65536) {
                     $type = 'text';
                 }
             }
         }
     } else {
         // Objects
         $reflectionClass = new \ReflectionClass($property->getType());
         $object = $reflectionClass->newInstance();
         if ($object instanceof \DateTime) {
             if ($property->hasCustomFlag('type')) {
                 $types = explode(':', strtolower($property->getCustomFlagValue('type')));
                 switch ($types[0]) {
                     case 'date':
                     case 'datetime':
                     case 'timestamp':
                         $type = $types[0];
                         break;
                     default:
                         throw new InvalidArgumentException(sprintf('DateTime property does not accept custom flag m:type(%s)', $types[0]));
                         break;
                 }
             } else {
                 $type = 'datetime';
             }
         }
     }
     return $type;
 }