00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00019 final class LightMetaProperty implements Stringable
00020 {
00021 private $name = null;
00022 private $columnName = null;
00023 private $className = null;
00024
00025 private $required = false;
00026 private $generic = false;
00027
00029 private $relationId = null;
00030
00032 private $strategyId = null;
00033
00037 public static function create()
00038 {
00039 return new self;
00040 }
00041
00045 public static function make(
00046 $name, $columnName, $className, $required,
00047 $generic, $relationId, $strategyId
00048 )
00049 {
00050 $self = new self;
00051
00052 $self->name = $name;
00053 $self->columnName = $columnName;
00054 $self->className = $className;
00055
00056 $self->required = $required;
00057 $self->generic = $generic;
00058
00059 $self->relationId = $relationId;
00060 $self->strategyId = $strategyId;
00061
00062 return $self;
00063 }
00064
00065 public function getName()
00066 {
00067 return $this->name;
00068 }
00069
00070 public function getColumnName()
00071 {
00072 return $this->columnName;
00073 }
00074
00078 public function setColumnName($name)
00079 {
00080 $this->columnName = $name;
00081
00082 return $this;
00083 }
00084
00085 public function getClassName()
00086 {
00087 return $this->className;
00088 }
00089
00090 public function isRequired()
00091 {
00092 return $this->required;
00093 }
00094
00098 public function setRequired($yrly)
00099 {
00100 $this->required = $yrly;
00101
00102 return $this;
00103 }
00104
00105 public function isGenericType()
00106 {
00107 return $this->generic;
00108 }
00109
00110 public function getRelationId()
00111 {
00112 return $this->relationId;
00113 }
00114
00115 public function getFetchStrategyId()
00116 {
00117 return $this->strategyId;
00118 }
00119
00123 public function setFetchStrategy(FetchStrategy $strategy)
00124 {
00125 $this->strategyId = $strategy->getId();
00126
00127 return $this;
00128 }
00129
00133 public function dropFetchStrategy()
00134 {
00135 $this->strategyId = null;
00136
00137 return $this;
00138 }
00139
00140 public function getContainerName($holderName)
00141 {
00142 return $holderName.ucfirst($this->getName()).'DAO';
00143 }
00144
00145 public function toString()
00146 {
00147 return
00148 'LightMetaProperty::make('
00149 ."'{$this->name}', "
00150 .(
00151 is_array($this->columnName)
00152 ? "array('".implode("', '", $this->columnName)."')"
00153 : "'".$this->columnName."'"
00154 )
00155 .', '
00156 .(
00157 $this->className
00158 ? "'{$this->className}'"
00159 : 'null'
00160 )
00161 .', '
00162 .(
00163 $this->required
00164 ? 'true'
00165 : 'false'
00166 )
00167 .', '
00168 .(
00169 $this->generic
00170 ? 'true'
00171 : 'false'
00172 )
00173 .', '
00174 .(
00175 $this->relationId
00176 ? "'".$this->relationId."'"
00177 : 'null'
00178 )
00179 .', '
00180 .(
00181 $this->strategyId
00182 ? $this->strategyId
00183 : 'null'
00184 )
00185 .')';
00186 }
00187 }
00188 ?>