本文整理汇总了PHP中StringHelper::endsWith方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::endsWith方法的具体用法?PHP StringHelper::endsWith怎么用?PHP StringHelper::endsWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::endsWith方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPrefix
/**
* Prefix to apply to properties loaded using <code>file</code>.
* A "." is appended to the prefix if not specified.
* @param string $prefix prefix string
* @return void
* @since 2.0
*/
function setPrefix($prefix)
{
$this->prefix = $prefix;
if (!StringHelper::endsWith(".", $prefix)) {
$this->prefix .= ".";
}
}
示例2: main
function main($_sourceFileName)
{
if ($this->fromPrefix === null || !StringHelper::startsWith($this->fromPrefix, $_sourceFileName) || !StringHelper::endsWith($this->fromPostfix, $_sourceFileName)) {
return null;
}
$varpart = $this->_extractVariablePart($_sourceFileName);
$substitution = $this->toPrefix . $varpart . $this->toPostfix;
return array($substitution);
}
示例3: setName
/**
* The name of the file, or the pattern for the name, that
* should be used for selection.
*
* @param pattern the file pattern that any filename must match
* against in order to be selected.
*/
public function setName($pattern) {
$pattern = str_replace('\\', DIRECTORY_SEPARATOR, $pattern);
$pattern = str_replace('/', DIRECTORY_SEPARATOR, $pattern);
if (StringHelper::endsWith(DIRECTORY_SEPARATOR, $pattern)) {
$pattern .= "**";
}
$this->pattern = $pattern;
}
示例4: MaskCheck
public static function MaskCheck($item, $masks)
{
$maskCheck = false;
foreach ($masks as $mask) {
if (\StringHelper::startsWith($item, $mask) || \StringHelper::endsWith($item, $mask)) {
$maskCheck = true;
}
}
return $maskCheck;
}
示例5: templateFileName
function templateFileName($templateName)
{
if ($templateName != null) {
if (!StringHelper::endsWith($templateName, '.html')) {
$templateName .= '.html';
}
return $templateName;
}
$rc = new ReflectionObject($this);
$filename = $rc->getName() . '.html';
return $filename;
}
示例6: normalizeSlashes
function normalizeSlashes($path)
{
// Url must not end with slash
while (StringHelper::endsWith($path, '/')) {
$path = substr($path, 0, -1);
}
// Url must start with slash
if (!StringHelper::startsWith($path, '/')) {
$path = '/' . $path;
}
return $path;
}
示例7: evaluate
function evaluate()
{
$osName = strtolower(Phing::getProperty("os.name"));
if ($this->family !== null) {
if ($this->family === "windows") {
return StringHelper::startsWith("win", $osName);
} elseif ($this->family === "mac") {
return strpos($osName, "mac") !== false || strpos($osName, "darwin") !== false;
} elseif ($this->family === "unix") {
return StringHelper::endsWith("ix", $osName) || StringHelper::endsWith("ux", $osName) || StringHelper::endsWith("bsd", $osName) || StringHelper::startsWith("sunos", $osName) || StringHelper::startsWith("darwin", $osName);
}
throw new BuildException("Don't know how to detect os family '" . $this->family . "'");
}
return false;
}
示例8: listFilesByType
/**
* Return files in a folder by type
* @param $folderPath
* @param $type
* @param $removeExtension
*/
public static function listFilesByType($folderPath, $type, $removeExtension = false) {
$results = null;
if (is_dir($folderPath)) {
$results = array();
if ($handle = opendir($folderPath)) {
while (($file = readdir($handle)) !== false) {
if (StringHelper::endsWith($file, $type)) {
if ($removeExtension) {
$results[] = substr($file, 0, strlen($file) - 4);
} else {
$results[] = $file;
}
}
}
closedir($handle);
}
}
return $results;
}
示例9: main
/**
* do the work
* @throws BuildException if required attributes are not supplied
* property and attribute are required attributes
*/
public function main()
{
if ($this->property === null) {
throw new BuildException("property attribute required", $this->getLocation());
}
if ($this->file == null) {
throw new BuildException("file attribute required", $this->getLocation());
}
$value = $this->file->getName();
if ($this->suffix != null && StringHelper::endsWith($this->suffix, $value)) {
// if the suffix does not starts with a '.' and the
// char preceding the suffix is a '.', we assume the user
// wants to remove the '.' as well
$pos = strlen($value) - strlen($this->suffix) - 1;
if ($pos > 0 && $this->suffix[0] !== '.' && $value[$pos] === '.') {
$pos--;
}
$value = StringHelper::substring($value, 0, $pos);
}
$this->getProject()->setNewProperty($this->property, $value);
}
示例10: nextQuery
/**
* Returns entire SQL source
*
* @return string|null
*/
public function nextQuery()
{
$sql = null;
while (($line = $this->sqlReader->readLine()) !== null) {
$delimiter = $this->parent->getDelimiter();
$project = $this->parent->getOwningTarget()->getProject();
$line = ProjectConfigurator::replaceProperties($project, trim($line), $project->getProperties());
if ($line != $delimiter && (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line))) {
continue;
}
$sql .= " " . $line . "\n";
/**
* fix issue with PDO and wrong formated multistatements
* @issue 1108
*/
if (StringHelper::endsWith($delimiter, $line)) {
break;
}
}
return $sql;
}
示例11: _slashify
/**
*
* Enter description here ...
* @param PhingFile|string $path
* @param boolean $isDirectory
* @return string
*/
public function _slashify($path, $isDirectory)
{
$p = (string) $path;
if (self::$separator !== '/') {
$p = str_replace(self::$separator, '/', $p);
}
if (!StringHelper::startsWith('/', $p)) {
$p = '/' . $p;
}
if (!StringHelper::endsWith('/', $p) && $isDirectory) {
$p = $p . '/';
}
return $p;
}
示例12: fromURIPath
function fromURIPath($p)
{
if (StringHelper::endsWith("/", $p) && strlen($p) > 1) {
// "/foo/" --> "/foo", but "/" --> "/"
$p = substr($p, 0, strlen($p) - 1);
}
return $p;
}
示例13: runStatements
/**
* read in lines and execute them
* @param Reader $reader
* @param null $out
* @throws BuildException
*/
public function runStatements(Reader $reader, $out = null)
{
$sql = "";
$line = "";
$buffer = '';
if (is_array($this->filterChains) && !empty($this->filterChains)) {
$in = FileUtils::getChainedReader(new BufferedReader($reader), $this->filterChains, $this->getProject());
while (-1 !== ($read = $in->read())) {
// -1 indicates EOF
$buffer .= $read;
}
$lines = explode("\n", $buffer);
} else {
$in = new BufferedReader($reader);
while (($line = $in->readLine()) !== null) {
$lines[] = $line;
}
}
try {
foreach ($lines as $line) {
$line = trim($line);
$line = ProjectConfigurator::replaceProperties($this->project, $line, $this->project->getProperties());
if (StringHelper::startsWith("//", $line) || StringHelper::startsWith("--", $line) || StringHelper::startsWith("#", $line)) {
continue;
}
if (strlen($line) > 4 && strtoupper(substr($line, 0, 4)) == "REM ") {
continue;
}
$sql .= " " . $line;
$sql = trim($sql);
// SQL defines "--" as a comment to EOL
// and in Oracle it may contain a hint
// so we cannot just remove it, instead we must end it
if (strpos($line, "--") !== false) {
$sql .= "\n";
}
if ($this->delimiterType == self::DELIM_NORMAL && StringHelper::endsWith($this->delimiter, $sql) || $this->delimiterType == self::DELIM_ROW && $line == $this->delimiter) {
$this->log("SQL: " . $sql, Project::MSG_VERBOSE);
$this->execSQL(StringHelper::substring($sql, 0, strlen($sql) - strlen($this->delimiter)), $out);
$sql = "";
}
}
// Catch any statements not followed by ;
if ($sql !== "") {
$this->execSQL($sql, $out);
}
} catch (SQLException $e) {
throw new BuildException("Error running statements", $e);
}
}
示例14: evalExpression
/**
* Evaluates expression and returns resulting value.
* @return mixed
*/
protected function evalExpression()
{
$this->log("Evaluating PHP expression: " . $this->expression);
if (!StringHelper::endsWith(';', trim($this->expression))) {
$this->expression .= ';';
}
$retval = null;
eval('$retval = ' . $this->expression);
return $retval;
}
示例15: throwableMessage
public static function throwableMessage(&$msg, $error, $verbose)
{
while ($error instanceof BuildException) {
$cause = $error->getCause();
if ($cause === null) {
break;
}
$msg1 = (string) $error;
$msg2 = (string) $cause;
if (StringHelper::endsWith($msg2, $msg1)) {
$msg .= StringHelper::substring($msg1, 0, strlen($msg1) - strlen($msg2));
$error = $cause;
} else {
break;
}
}
if ($verbose || !$error instanceof BuildException) {
$msg .= (string) $error;
} else {
$msg .= $error->getMessage() . PHP_EOL;
}
}