Beispiel #1
0
 /**
  * Returns the value
  *
  * @param bool whether to get the modified or original version
  * @return string
  */
 public function get($modified = true)
 {
     //argument 1 must be a bool
     Eden_Type_Error::i()->argument(1, 'bool');
     return $modified ? $this->_data : $this->_original;
 }
Beispiel #2
0
 /**
  * Summarizes a text
  *
  * @param int number of words
  * @return this
  */
 public function summarize($words)
 {
     //argument 1 must be a string
     Eden_Type_Error::i()->argument(1, 'int');
     $this->_data = explode(' ', strip_tags($this->_data), $words);
     array_pop($this->_data);
     $this->_data = implode(' ', $this->_data);
     return $this;
 }
Beispiel #3
0
 /**
  * Sets data
  *
  * @return this
  */
 public function set($value)
 {
     Eden_Type_Error::i()->argument(1, 'array');
     $this->_data = $value;
     return $this;
 }
Beispiel #4
0
if(!class_exists('Eden_Type_String')){class Eden_Type_String extends Eden_Type_Abstract{protected static $_methods=array( 'addslashes'=>self::PRE,'bin2hex'=>self::PRE,'chunk_split'=>self::PRE,'convert_uudecode'=>self::PRE,'convert_uuencode'=>self::PRE,'crypt'=>self::PRE,'html_entity_decode'=>self::PRE,'htmlentities'=>self::PRE,'htmlspecialchars_decode'=>self::PRE,'htmlspecialchars'=>self::PRE,'lcfirst'=>self::PRE,'ltrim'=>self::PRE,'md5'=>self::PRE,'nl2br'=>self::PRE,'quoted_printable_decode'=>self::PRE,'quoted_printable_encode'=>self::PRE,'quotemeta'=>self::PRE,'rtrim'=>self::PRE,'sha1'=>self::PRE,'sprintf'=>self::PRE,'str_pad'=>self::PRE,'str_repeat'=>self::PRE,'str_rot13'=>self::PRE,'str_shuffle'=>self::PRE,'strip_tags'=>self::PRE,'stripcslashes'=>self::PRE,'stripslashes'=>self::PRE,'strpbrk'=>self::PRE,'stristr'=>self::PRE,'strrev'=>self::PRE,'strstr'=>self::PRE,'strtok'=>self::PRE,'strtolower'=>self::PRE,'strtoupper'=>self::PRE,'strtr'=>self::PRE,'substr_replace'=>self::PRE,'substr'=>self::PRE,'trim'=>self::PRE,'ucfirst'=>self::PRE,'ucwords'=>self::PRE,'vsprintf'=>self::PRE,'wordwrap'=>self::PRE,'count_chars'=>self::PRE,'hex2bin'=>self::PRE,'strlen'=>self::PRE,'strpos'=>self::PRE,'substr_compare'=>self::PRE,'substr_count'=>self::PRE,'str_ireplace'=>self::POST,'str_replace'=>self::POST,'preg_replace'=>self::POST,'explode'=>self::POST);public static function i(){return self::_getMultiple(__CLASS__);}public function __construct($data){Eden_Type_Error::i()->argument(1,'scalar');$data=(string) $data;parent::__construct($data);}public function __toString(){return $this->_data;}public function camelize($prefix='-'){Eden_Type_Error::i()->argument(1,'string');$this->_data=str_replace($prefix,' ',$this->_data);$this->_data=str_replace(' ','',ucwords($this->_data));$this->_data=strtolower(substr($name,0,1)).substr($name,1);return $this;}public function dasherize(){$this->_data=preg_replace("/[^a-zA-Z0-9_-\s]/i",'',$this->_data);$this->_data=str_replace(' ','-',trim($this->_data));$this->_data=preg_replace("/-+/i",'-',$this->_data);$this->_data=strtolower($this->_data);return $this;}public function titlize($prefix='-'){Eden_Type_Error::i()->argument(1,'string');$this->_data=ucwords(str_replace($prefix,' ',$this->_data));return $this;}public function uncamelize($prefix='-'){Eden_Type_Error::i()->argument(1,'string');$this->_data=strtolower(preg_replace("/([A-Z])/",$prefix."$1",$this->_data));return $this;}public function summarize($words){Eden_Type_Error::i()->argument(1,'int');$this->_data=explode(' ',strip_tags($this->_data),$words);array_pop($this->_data);$this->_data=implode(' ',$this->_data);return $this;}protected function _getMethodType(&$name){if(isset(self::$_methods[$name])){return self::$_methods[$name];}if(isset(self::$_methods['str_'.$name])){$name='str_'.$name;return self::$_methods[$name];}$uncamel=strtolower(preg_replace("/([A-Z])/","_$1",$name));if(isset(self::$_methods[$uncamel])){$name=$uncamel;return self::$_methods[$name];}if(isset(self::$_methods['str_'.$uncamel])){$name='str_'.$uncamel;return self::$_methods[$name];}return false;}}}