StringType.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2006-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00015     class StringType extends BasePropertyType
00016     {
00017         public function getPrimitiveName()
00018         {
00019             return 'string';
00020         }
00021         
00026         public function setDefault($default)
00027         {
00028             Assert::isString(
00029                 $default,
00030                 "strange default value given - '{$default}'"
00031             );
00032             
00033             $this->default = $default;
00034             
00035             return $this;
00036         }
00037         
00038         public function getDeclaration()
00039         {
00040             if ($this->hasDefault())
00041                 return "'{$this->default}'";
00042             
00043             return 'null';
00044         }
00045         
00046         public function isMeasurable()
00047         {
00048             return true;
00049         }
00050         
00051         public function toColumnType($length = null)
00052         {
00053             return
00054                 $length
00055                     ? 'DataType::create(DataType::VARCHAR)'
00056                     : 'DataType::create(DataType::TEXT)';
00057         }
00058     }
00059 ?>