/** * Filter: removes unnecessary whitespace and shortens value to control's max length. * @return string */ public function sanitize($value) { if ($this->control->maxlength && iconv_strlen($value, 'UTF-8') > $this->control->maxlength) { $value = iconv_substr($value, 0, $this->control->maxlength, 'UTF-8'); } return String::trim(strtr($value, "\r\n", ' ')); }
private static function renderFile(&$loader, $origTempUri, $origTempPath, $key, $files) { $controlId = basename(substr($key, 0, strpos($key, '||'))); // ak je to nejaky subor z modulu [vzdy ulozeny v zlozke 'web'], tak chceme zachovat meno podla 3.parametra if ($controlId == 'web') { $dirname = substr($key, strpos($key, '||') + 2); $pathSuffix = Basic::getBaseDirName($dirname); $srcPath = str_replace(array('||', $pathSuffix . '/'), array('', ''), $key); } else { $dirname = $controlId . '/' . substr($key, strpos($key, '||') + 2); $srcPath = str_replace('||', '', $key); } $dirname = String::trim($dirname, '/'); //todo: overit, ci to nebude robit adresare zase inde..zistit, cim to je, ze to na locale ide a na ostrom serveri nie // pouzit ked tak Environment::getVariable('webtempDir') Basic::mkdir($origTempPath . '/' . $dirname); $loader->sourcePath = $srcPath; $loader->tempUri = $origTempUri . '/' . $dirname; $loader->tempPath = $origTempPath . '/' . $dirname; $loader->render($files); }
/** * trim test. * @return void */ public function testTrim() { $this->assertEquals("x", String::trim(" \t\n\r\v x")); $this->assertEquals("", String::trim("�x�")); $this->assertEquals("a b", String::trim(" a b ")); $this->assertEquals(" a b ", String::trim(" a b ", '')); $this->assertEquals("e", String::trim("Ře-", "Ř-")); // Ře- }
/** * Sets the plain message. * * @param string $message * @return Email */ public function setPlainMessage($message) { if (!$message instanceof String) { $message = new String($message); } $this->messages["plain"] = $message->trim()->regEx("#(\r\n|\r|\n)#", $this->headerSeparator); return $this; }
public function testTrim() { $string = new String("Test13 "); $this->assertEquals("Test13", $string->trim()); }
<?php class String { private $_string; public function __construct($string) { $this->_string = $string; } public function __call($method, $arguments) { $this->_string = call_user_func($method, $this->_string); return $this; } public function getValue() { return $this->_string; } } $test = new String(' test, test2 '); $test->trim(); var_dump($test->getValue()); $test->strlen(); var_dump($test->getValue());
public function testTrim() { $string = new String(" Hello World "); $this->assertTrue($string->trim()->equals("Hello World")); $string = new String("/*/*/Hello World/*/*/"); $this->assertTrue($string->trim("/*")->equals("Hello World")); $str = <<<STR aiueo STR; $string = new String($str); $this->assertTrue($string->trim()->equals("aiueo")); // multibyte $string = new String(" あいうえお "); $this->assertTrue($string->trim()->equals("あいうえお")); $string = new String("表能申あいうえお申能表"); $this->assertTrue($string->trim("表能申")->equals("あいうえお")); $str = <<<STR あいうえお STR; $string = new String($str); $this->assertTrue($string->trim()->equals("あいうえお")); }