예제 #1
0
 /**
  * 创建toArray方法
  *
  * @param array $sets
  * @return string
  */
 public function toToArray(array $sets)
 {
     $items = array(str_repeat($this->_tab, 2) . 'return array(');
     $citem = array();
     $lenArr = array_map(function ($name) {
         return mb_strlen($name);
     }, $sets);
     sort($lenArr);
     $maxLen = array_pop($lenArr) + 1;
     foreach ($sets as $name) {
         $len = $maxLen - mb_strlen($name);
         $citem[] = str_repeat($this->_tab, 3) . '\'' . $name . '\'' . str_repeat(' ', $len) . '=> $this->_' . lcfirst(\Lib\Func::ucc($name));
     }
     $items[] = implode(',' . "\n", $citem);
     unset($citem);
     $items[] = str_repeat($this->_tab, 2) . ");";
     return $this->toFunc('toArray', $items);
 }
예제 #2
0
 /**
  * 创建get方法内容
  *
  * @param \Model\Columnstruct $struct
  * @param array $commentArr
  */
 protected function buildGetfuncContent(\Model\Columnstruct $struct, array $commentArr)
 {
     $build = \Model\Build::getInstance();
     $buffer = \Model\Buffer::getInstance();
     $name = strtolower($struct->getColumn_name());
     $propName = lcfirst(\Lib\Func::ucc($name));
     $commentArr[] = '@return ' . $this->getDateType($struct->getData_type());
     $buffer->pushFunc($build->toComment($commentArr));
     $buffer->pushFunc($build->toGetFunc(ucfirst($name), array(str_repeat($this->_tab, 2) . 'return $this->_' . $propName . ';')));
 }