Doctrine\ODM\CouchDB\Types\Type::getType PHP Метод

getType() публичный статический Метод

Type instances are implemented as flyweights.
public static getType ( string $name ) : Type
$name string The name of the type (as returned by getName()).
Результат Type
    public static function getType($name)
    {
        if (!isset(self::$_typeObjects[$name])) {
            if (!isset(self::$_typesMap[$name])) {
                throw TypeException::unknownType($name);
            }
            self::$_typeObjects[$name] = new self::$_typesMap[$name]();
        }
        return self::$_typeObjects[$name];
    }

Usage Example

 /**
  * @return array
  */
 public function jsonSerialize()
 {
     $output = array();
     foreach (get_object_vars($this) as $key => $value) {
         if ($value instanceof \DateTime) {
             // Clumsy way to avoid writing mappings for sub-documents and all that.
             $output[$key] = Type::getType('datetime')->convertToCouchDBValue($value);
         } else {
             $output[$key] = $value;
         }
     }
     return array_filter($output);
 }
All Usage Examples Of Doctrine\ODM\CouchDB\Types\Type::getType