本文整理汇总了PHP中Nette\Utils\Strings::upper方法的典型用法代码示例。如果您正苦于以下问题:PHP Strings::upper方法的具体用法?PHP Strings::upper怎么用?PHP Strings::upper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Strings
的用法示例。
在下文中一共展示了Strings::upper方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
示例2: 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));
}
示例3: 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));
}
示例4: 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));
}
示例5: 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));
}
示例6: decode
public static function decode($string)
{
$digits = ['I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000];
$string = Strings::upper($string);
if (!Strings::match($string, '#[IVXLCDMN]+#')) {
throw new \InvalidArgumentException('Malformed symbol detected. Allowed symbols are: IVXLCDMN');
}
if (count(explode('V', $string)) > 2 || count(explode('L', $string)) > 2 || count(explode('D', $string)) > 2) {
throw new \InvalidArgumentException('Multiple occurencies of V, L or D symbols');
}
if ($string === 'N') {
return 0;
}
$count = 1;
$last = 'Z';
foreach (str_split($string) as $char) {
if ($char === $last) {
$count++;
if ($count === 4) {
throw new \InvalidArgumentException('Malformed Roman number');
}
} else {
$count = 1;
$last = $char;
}
}
$ptr = 0;
$values = [];
$maxDigit = 1000;
while ($ptr < strlen($string)) {
$numeral = $string[$ptr];
$digit = $digits[$numeral];
if ($digit > $maxDigit) {
throw new \InvalidArgumentException('Rule 3');
}
if ($ptr < strlen($string) - 1) {
$nextNumeral = $string[$ptr + 1];
$nextDigit = $digits[$nextNumeral];
if ($nextDigit > $digit) {
if (!in_array($numeral, ['I', 'X', 'C']) || $nextDigit > $digit * 10 || count(explode($numeral, $string)) > 2) {
throw new \InvalidArgumentException('Rule 3');
}
$maxDigit = $digit - 1;
$digit = $nextDigit - $digit;
$ptr++;
}
}
$values[] = $digit;
$ptr++;
}
for ($i = 0; $i < count($values) - 1; $i++) {
if ($values[$i] < $values[$i + 1]) {
throw new \InvalidArgumentException('Rule 5');
}
}
return array_sum($values);
}
示例7: 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);
}
示例8: hashPassword
/**
* Computes salted password hash.
* @param string
* @return string
*/
public static function hashPassword($password, $options = NULL)
{
if ($password === Strings::upper($password)) {
// perhaps caps lock is on
$password = Strings::lower($password);
}
$password = substr($password, 0, self::PASSWORD_MAX_LENGTH);
$options = $options ?: implode('$', array('algo' => PHP_VERSION_ID < 50307 ? '$2a' : '$2y', 'cost' => '07', 'salt' => Strings::random(22)));
return crypt($password, $options);
}
示例9: 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);
}
示例10: processCons
public function processCons()
{
$arr = [];
foreach (Arrays::get($this->data, 'constants', []) as $name => $cons) {
if ($this->getDefault($cons) != ";") {
$arr[] = "\$" . Strings::upper($name) . $this->getDefault($cons);
}
}
$this->template->constants = $arr;
}
示例11: testRenderWithRenderer
public function testRenderWithRenderer()
{
$test = $this;
$this->column->setRenderer(function ($value, $rowData, $cell) use($test) {
$test->assertTrue(is_string($value));
$test->assertInstanceOf('stdClass', $rowData);
$test->assertInstanceOf('Nette\\Utils\\Html', $cell);
return \Nette\Utils\Strings::upper($value);
});
$result = $this->column->render(array('testing', 'is', 'awesome'), array());
$this->assertEquals('TESTING, IS, AWESOME', $result);
}
示例12: actionGetData
/**
* Akce vracející data description a konfiguraci pro EasyMiner UI
* @param int $id_dm
* @param int $miner
* @throws ForbiddenRequestException
*/
public function actionGetData($id_dm, $miner)
{
if (empty($miner)) {
$miner = $id_dm;
}
//------------------------------------------------------------------------------------------------------------------
$miner = $this->findMinerWithCheckAccess($miner);
$minerType = $miner->type;
$FLPathElement = 'FLPath_' . Strings::upper($minerType);
//------------------------------------------------------------------------------------------------------------------
#region připravení informací pro UI - s odděleným připravením DataDictionary
$dataDescriptionPMML = null;
$dataParser = new DataParser($dataDescriptionPMML, $this->config->{$FLPathElement}, $this->config->FGCPath, null, null, $this->translator->getLang());
$dataParser->loadData();
$responseContent = $dataParser->parseData();
$user = $this->getCurrentUser();
$responseContent['DD'] = ['dataDictionary' => $this->datasourcesFacade->exportDataDictionaryArr($miner->datasource, $user, $rowsCount), 'transformationDictionary' => $this->metasourcesFacade->exportTransformationDictionaryArr($miner->metasource, $user), 'recordCount' => $rowsCount];
#endregion připravení informací pro UI - s odděleným připravením DataDictionary
uksort($responseContent['DD']['transformationDictionary'], function ($a, $b) {
return strnatcasecmp($a, $b);
});
uksort($responseContent['DD']['dataDictionary'], function ($a, $b) {
return strnatcasecmp($a, $b);
//return strnatcasecmp(mb_strtolower($a,'utf-8'),mb_strtolower($b,'utf-8'));
});
$responseContent['status'] = 'ok';
$responseContent['miner_type'] = $miner->type;
$responseContent['miner_name'] = $miner->name;
if ($miner->ruleSet) {
$ruleSet = $miner->ruleSet;
} else {
$ruleSet = $this->ruleSetsFacade->saveNewRuleSetForUser($miner->name, $this->getCurrentUser());
$miner->ruleSet = $ruleSet;
$this->minersFacade->saveMiner($miner);
}
$responseContent['miner_ruleset'] = ['id' => $ruleSet->ruleSetId, 'name' => $ruleSet->name];
$responseContent['miner_config'] = $miner->getExternalConfig();
$this->sendJsonResponse($responseContent);
}
示例13: createPresenterName
private function createPresenterName($string)
{
$presenter = '';
$enlarge = false;
for ($i = 0; $i < \Nette\Utils\Strings::length($string); $i++) {
$char = \Nette\Utils\Strings::substring($string, $i, 1);
if ($char == '-') {
$enlarge = true;
}
if (ord($char) >= 65 && ord($char) <= 90 || ord($char) >= 97 && ord($char) <= 122) {
if ($i == 0 || $enlarge) {
$presenter .= \Nette\Utils\Strings::upper($char);
if ($enlarge) {
$enlarge = false;
}
} else {
$presenter .= $char;
}
}
}
return $presenter;
}
示例14: doDecorate
/**
* @param PhpNamespace $namespace
* @param ClassType $class
* @param Column $column
* @return void
*/
public function doDecorate(Column $column, ClassType $class, PhpNamespace $namespace)
{
$column->setPhpDoc($doc = new PhpDoc());
// Annotation
$doc->setAnnotation('@property');
// Type
if ($column->isNullable()) {
$doc->setType($this->getRealType($column) . '|NULL');
} else {
$doc->setType($this->getRealType($column));
}
// Variable
$doc->setVariable(Helpers::camelCase($column->getName()));
// Defaults
if ($column->getDefault() !== NULL) {
$doc->setDefault($this->getRealDefault($column));
}
// Enum
if (!empty($enum = $column->getEnum())) {
$doc->setEnum(Strings::upper($column->getName()));
}
// Relations
if (($key = $column->getForeignKey()) !== NULL) {
// Find foreign entity table
$ftable = $column->getTable()->getDatabase()->getForeignTable($key->getReferenceTable());
// Update type to Entity name
$doc->setType($this->resolver->resolveEntityName($ftable));
$doc->setRelation($relDoc = new PhpRelDoc());
if ($use = $this->getRealUse($ftable, $namespace)) {
$namespace->addUse($use);
}
$relDoc->setType('???');
$relDoc->setEntity($this->resolver->resolveEntityName($ftable));
$relDoc->setVariable('???');
}
// Append phpDoc to class
$class->addDocument((string) $column->getPhpDoc());
}
示例15: doDecorate
/**
* @param PhpNamespace $namespace
* @param ClassType $class
* @param Column $column
* @return void
*/
public function doDecorate(Column $column, ClassType $class, PhpNamespace $namespace)
{
switch ($column->getType()) {
// Map: DateTime
case ColumnTypes::TYPE_DATETIME:
$column->setType('DateTime');
if ($column->getDefault() !== NULL) {
$column->setDefault('now');
}
$namespace->addUse('Nette\\Utils\\DateTime');
break;
// Map: Enum
// Map: Enum
case ColumnTypes::TYPE_ENUM:
foreach ($column->getEnum() as $enum) {
$name = Strings::upper($column->getName()) . '_' . $enum;
$class->addConst($name, $enum);
}
if ($column->getDefault() !== NULL) {
$column->setDefault(Strings::upper($column->getName()) . '_' . $column->getDefault());
}
break;
}
}