本文整理汇总了PHP中Nette\Utils\Strings::lower方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::lower方法的具体用法?PHP Strings::lower怎么用?PHP Strings::lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Strings
的用法示例。
在下文中一共展示了Strings::lower方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: constructUrl
public function constructUrl(Request $appRequest, Url $refUrl)
{
// Module prefix not match.
if ($this->module && !Strings::startsWith($appRequest->getPresenterName(), $this->module)) {
return null;
}
$params = $appRequest->getParameters();
$urlStack = [];
// Module prefix
$moduleFrags = explode(":", Strings::lower($appRequest->getPresenterName()));
$resourceName = array_pop($moduleFrags);
$urlStack += $moduleFrags;
// Resource
$urlStack[] = Strings::lower($resourceName);
// Id
if (isset($params['id']) && is_scalar($params['id'])) {
$urlStack[] = $params['id'];
unset($params['id']);
}
// Set custom action
if (isset($params['action']) && $this->_isApiAction($params['action'])) {
unset($params['action']);
}
$url = $refUrl->getBaseUrl() . implode('/', $urlStack);
// Add query parameters
if (!empty($params)) {
$url .= "?" . http_build_query($params);
}
return $url;
}
示例2: copy
private function copy($dir, $targetDir)
{
$files = [];
/** @var $file \SplFileInfo */
foreach (Finder::find('*')->from($dir) as $file) {
if ($file->isFile()) {
$filename = $this->getRelativePath($file->getPathname(), $dir);
$files[$filename] = $file;
}
}
foreach ($files as $filename => $file) {
$target = $targetDir . '/' . $filename;
$dir = (new \SplFileInfo($target))->getPath();
if (!file_exists($dir)) {
umask(00);
mkdir($dir, 0777, true);
}
if (Strings::lower($file->getExtension()) == 'zip' && extension_loaded('zlib')) {
$archive = new \ZipArchive();
$res = $archive->open($file->getRealPath());
if ($res === true) {
$archive->extractTo($targetDir);
$archive->close();
}
continue;
}
@copy($file->getPathname(), $target);
}
}
示例3: init
/**
* Method run before install
*
* @throws \Canterville\NonExistsException
* @throws \Canterville\Exception\NotSetException
*/
protected function init()
{
$this->url = $this->getUrl($this->version);
$this->distType = $this->getDistType($this->url);
$this->targetDir = $this->getVendorDir() . self::AUTHOR_DIR . Strings::lower($this->name) . '/';
$calledClass = get_called_class();
if (!method_exists($calledClass, 'copyToBinFolder')) {
throw new NotExistsException(sprintf('Method "' . $calledClass . '::%s" non exists.', 'copyToBinFolder'));
}
$errorMsg = 'Property "' . $calledClass . '::$%s" not set.';
if (!isset($this->name)) {
throw new NotSetException($errorMsg, 'name');
}
if (!isset($this->version)) {
throw new NotSetException($errorMsg, 'version');
}
if (!isset($this->url)) {
throw new NotSetException($errorMsg, 'url');
}
if (!isset($this->distType)) {
throw new NotSetException($errorMsg, 'distType');
}
if (!isset($this->targetDir)) {
throw new NotSetException($errorMsg, 'targetDir');
}
}
示例4: generateHash
/**
* Generuje hash hesla i se solicim retezcem
* @return string
*/
public function generateHash($heslo, $salt = NULL)
{
if ($heslo === Strings::upper($heslo)) {
// v pripade zapleho capslocku
$heslo = Strings::lower($heslo);
}
return crypt($heslo, $salt ?: '$2a$07$' . Strings::random(23));
}
示例5: addDynamicAction
/**
* Adds dynamic action
* @param string $title
* @param bool $ajax
* @return DynamicAction
*/
public function addDynamicAction($title, $ajax = false)
{
$title = Strings::lower($title);
$action = new \Gridder\Actions\DynamicAction($this, $title);
$action->setTitle($title);
$action->setAjax($ajax);
return $action;
}
示例6: isComposerVendorNameProtectionFree
public function isComposerVendorNameProtectionFree($composerFullName)
{
$composerVendor = NULL;
if (($data = Strings::match($composerFullName, Addon::COMPOSER_NAME_RE)) !== NULL) {
$composerVendor = Strings::lower($data['vendor']);
}
return !in_array($composerVendor, $this->protectedVendors);
}
示例7: calculateAddonsPortalPasswordHash
/**
* @param string
* @param string|NULL
* @return string
*/
private function calculateAddonsPortalPasswordHash($password, $salt = NULL)
{
if ($password === Strings::upper($password)) {
// perhaps caps lock is on
$password = Strings::lower($password);
}
return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
}
示例8: calculateHash
/**
* Computes password hash.
*
* @param string
* @param string|NULL
* @return string
*/
public static function calculateHash($password, $salt = NULL)
{
if ($password === Strings::upper($password)) {
// perhaps caps lock is on
$password = Strings::lower($password);
}
return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
}
示例9: setEmail
public function setEmail($email)
{
/**
* Not according to RFC 5321, but as per SO this is ok
* @see http://stackoverflow.com/a/9808332/326257
*/
$this->setValue('email', $email ? Strings::lower($email) : NULL);
}
示例10: generateHash
/**
* Generuje hash hesla i se solicim retezcem
* @return string
*/
public function generateHash($password, $salt = NULL)
{
if ($password === Strings::upper($password)) {
// v pripade zapleho capslocku
$password = Strings::lower($password);
}
return crypt($password, $salt ?: $this->user_salt . Strings::random(23));
}
示例11: macroIfAllowedLink
/**
* @param MacroNode $node
* @param PhpWriter $writer
*
* @return string
*
* @throws CompileException
*/
public static function macroIfAllowedLink(MacroNode $node, PhpWriter $writer)
{
// This macro is allowed only as n:macro in <a ></a> element
if (Utils\Strings::lower($node->htmlNode->name) != 'a') {
throw new CompileException("Macro n:allowedHref is allowed only in link element, you used it in {$node->htmlNode->name}.");
}
return $writer->write('if($presenter->context->getByType("IPub\\Permissions\\Access\\LinkChecker")->isAllowed(%node.word)){');
}
示例12: calculateHash
/**
* Computes salted password hash.
* @param string
* @return string
*/
public static function calculateHash($password, $salt = NULL)
{
if ($password === Strings::upper($password)) {
// perhaps caps lock is on
$password = Strings::lower($password);
}
$password = substr($password, 0, self::PASSWORD_MAX_LENGTH);
return crypt($password, $salt ?: '$2a$07$' . Strings::random(22));
}
示例13: hashPassword
/**
* Computes salted password hash.
*
* @param $password
* @param null $options
* @return string
*/
public static function hashPassword($password, $options = NULL)
{
if ($password === Nette\Utils\Strings::upper($password)) {
// perhaps caps lock is on
$password = Nette\Utils\Strings::lower($password);
}
$password = substr($password, 0, 4096);
$options = $options ?: implode('$', ['algo' => PHP_VERSION_ID < 50307 ? '$2a' : '$2y', 'cost' => '07', 'salt' => Nette\Utils\Strings::random(22)]);
return crypt($password, $options);
}
示例14: spinalCase
/**
* Converts the given string to `spinal-case`
* @param string $string
* @return string
*/
public static function spinalCase($string)
{
/** RegExp source http://stackoverflow.com/a/1993772 */
preg_match_all('/([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)/', $string, $matches);
$matches = $matches[0];
foreach ($matches as &$match) {
$match = $match == Strings::upper($match) ? Strings::lower($match) : Strings::firstLower($match);
}
return implode('-', $matches);
}
示例15: getIcon
/**
* @param string $ext
* @return string
*/
public static final function getIcon($ext)
{
$ext = \Nette\Utils\Strings::lower($ext);
foreach (self::$ICONS as $icon => $extensions) {
if (in_array($ext, $extensions)) {
return $icon;
}
}
return self::$DEFAULT_ICON;
}