示例#1
0
文件: StringType.php 项目: kzap/Type
 /**
  * Summarizes a text
  *
  * @param int number of words
  * @return Eden\Type\Type\StringType
  */
 public function summarize($words)
 {
     //argument 1 must be an integer
     Argument::i()->test(1, 'int');
     $this->data = explode(' ', strip_tags($this->data), $words);
     array_pop($this->data);
     $this->data = implode(' ', $this->data);
     return $this;
 }
示例#2
0
文件: ArrayType.php 项目: kzap/Type
 /**
  * sets data using the Serializable interface
  *
  * @param string
  * @return Eden\Type\Type\ArrayType
  */
 public function unserialize($data)
 {
     //argument 1 must be a string
     Argument::i()->test(1, 'string');
     $this->data = json_decode($data, true);
     return $this;
 }