class Str

Methods

static string
random(int $length = 16)

The MIT License (MIT)

static string
quickRandom(int $length = 16)

The MIT License (MIT)

static string
convertLineFeed($value, string $lf = "\n")

改行コードの変換

static string
characterEncoding($value, $encoding = array('UTF-8', 'SJIS', 'EUC-JP', 'ASCII', 'JIS', 'sjis-win'))

文字コードの判定

static string
ellipsis(string $value, int $length = 100, string $end = '...')

指定した文字列以上ある場合、「.

static string
timeAgo($date)

現在からの経過時間を書式化する.

static boolean
isBlank(string $value, boolean $greedy = false)

変数が空白かどうかをチェックする.

static bool
isNotBlank($value, $greedy = false)

No description

static string
trimAll($value)

両端にある全角スペース、半角スペースを取り除く

Details

at line 61
static string random(int $length = 16)

The MIT License (MIT)

Copyright (c)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

Generate a more truly "random" alpha-numeric string.

Parameters

int $length

Return Value

string

Exceptions

RuntimeException

at line 106
static string quickRandom(int $length = 16)

The MIT License (MIT)

Copyright (c)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

Generate a "random" alpha-numeric string.

Should not be considered sufficient for cryptography, etc.

Parameters

int $length

Return Value

string

at line 121
static string convertLineFeed($value, string $lf = "\n")

改行コードの変換

Parameters

$value
string $lf

Return Value

string

at line 135
static string characterEncoding($value, $encoding = array('UTF-8', 'SJIS', 'EUC-JP', 'ASCII', 'JIS', 'sjis-win'))

文字コードの判定

Parameters

$value
$encoding

Return Value

string

at line 156
static string ellipsis(string $value, int $length = 100, string $end = '...')

指定した文字列以上ある場合、「.

..」を付加する lengthに7を指定すると、「1234567890」は「1234567...」と「...」を付与して出力される

Parameters

string $value
int $length
string $end

Return Value

string

at line 172
static string timeAgo($date)

現在からの経過時間を書式化する.

Parameters

$date

Return Value

string

at line 228
static boolean isBlank(string $value, boolean $greedy = false)

変数が空白かどうかをチェックする.

引数 $value が空白かどうかをチェックする. 空白の場合は true. 以下の文字は空白と判断する. - ' ' (ASCII 32 (0x20)), 通常の空白 - "\t" (ASCII 9 (0x09)), タブ - "\n" (ASCII 10 (0x0A)), リターン - "\r" (ASCII 13 (0x0D)), 改行 - "\0" (ASCII 0 (0x00)), NULバイト - "\x0B" (ASCII 11 (0x0B)), 垂直タブ

引数 $value がオブジェクト型、配列の場合は非推奨とし、 EUSERDEPRECATED をスローする. EC-CUBE2系からの互換性、ビギナー層を配慮し、以下のような実装とする. 引数 $value が配列の場合は, 空の配列の場合 true を返す. 引数 $value が ArrayCollection::isEmpty() == true の場合 true を返す. 引数 $value が上記以外のオブジェクト型の場合は false を返す.

引数 $greedy が true の場合は, 全角スペース, ネストした空の配列も 空白と判断する.

Parameters

string $value チェック対象の変数. 文字型以外も使用できるが、非推奨.
boolean $greedy '貧欲'にチェックを行う場合 true, デフォルト false

Return Value

boolean $value が空白と判断された場合 true

at line 290
static bool isNotBlank($value, $greedy = false)

Parameters

$value
$greedy

Return Value

bool

at line 301
static string trimAll($value)

両端にある全角スペース、半角スペースを取り除く

Parameters

$value

Return Value

string