Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00015 abstract class BasePropertyType
00016 {
00017 abstract public function getDeclaration();
00018 abstract public function isMeasurable();
00019 abstract public function toColumnType();
00020 abstract public function getPrimitiveName();
00021
00022 protected $default = null;
00023
00024 public function isGeneric()
00025 {
00026 return true;
00027 }
00028
00029 public function toMethods(
00030 MetaClass $class,
00031 MetaClassProperty $property,
00032 MetaClassProperty $holder = null
00033 )
00034 {
00035 return
00036 $this->toGetter($class, $property, $holder)
00037 .$this->toSetter($class, $property, $holder);
00038 }
00039
00040 public function hasDefault()
00041 {
00042 return ($this->default !== null);
00043 }
00044
00045 public function getDefault()
00046 {
00047 return $this->default;
00048 }
00049
00050 public function setDefault($default)
00051 {
00052 throw new UnsupportedMethodException(
00053 'only generic non-object types can have default values atm'
00054 );
00055 }
00056
00057 public function toGetter(
00058 MetaClass $class,
00059 MetaClassProperty $property,
00060 MetaClassProperty $holder = null
00061 )
00062 {
00063 if ($holder)
00064 $name = $holder->getName().'->get'.ucfirst($property->getName()).'()';
00065 else
00066 $name = $property->getName();
00067
00068 $methodName = 'get'.ucfirst($property->getName());
00069
00070 return <<<EOT
00071
00072 public function {$methodName}()
00073 {
00074 return \$this->{$name};
00075 }
00076
00077 EOT;
00078 }
00079
00080 public function toSetter(
00081 MetaClass $class,
00082 MetaClassProperty $property,
00083 MetaClassProperty $holder = null
00084 )
00085 {
00086 $name = $property->getName();
00087 $methodName = 'set'.ucfirst($name);
00088
00089 if ($holder) {
00090 return <<<EOT
00091
00095 public function {$methodName}(\${$name})
00096 {
00097 \$this->{$holder->getName()}->{$methodName}(\${$name});
00098
00099 return \$this;
00100 }
00101
00102 EOT;
00103 } else {
00104 return <<<EOT
00105
00109 public function {$methodName}(\${$name})
00110 {
00111 \$this->{$name} = \${$name};
00112
00113 return \$this;
00114 }
00115
00116 EOT;
00117 }
00118
00119 Assert::isUnreachable();
00120 }
00121
00122 public function getHint()
00123 {
00124 return null;
00125 }
00126 }
00127 ?>