\Pluf_Utils

ابزارها و متدهای پرکاربرد

در این کلاس یک سری از متدهای پرکاربرد به صورت متدهای ایستا پیاده سازی شده است.

Summary

Methods
Properties
Constants
getRandomString()
getRandomAlphanumericString()
getRandomNumericString()
getPassword()
cleanFileName()
prettySize()
isValidEmail()
isValidUrl()
itemsToArray()
runExternal()
urlsafe_b64encode()
urlsafe_b64decode()
flattenArray()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

getRandomString()

getRandomString(  $len = 35) : string

Produces a random string.

Parameters

$len

Returns

string —

Random string

getRandomAlphanumericString()

getRandomAlphanumericString(  $len = 35) : string

Produces a random string contains only alphanumeric characters

Parameters

$len

Returns

string —

Random string

getRandomNumericString()

getRandomNumericString(  $len = 10) : string

Produces a random string contains only numeric characters

Parameters

$len

Returns

string —

Random string

getPassword()

getPassword(  $len = 8) : string

Produces a random password.

The random password generator avoid characters that can be confused like 0,O,o,1,l,I.

Parameters

$len

Returns

string —

Password

cleanFileName()

cleanFileName(  $name) : string

Clean the name of a file to only have alphanumeric characters.

Parameters

$name

Returns

string —

Clean name

prettySize()

prettySize(  $size) 

Parameters

$size

isValidUrl()

isValidUrl(  $url) 

Validate an url.

Only the structure is checked, no check of availability of the url is performed. It is a really basic validation.

Parameters

$url

itemsToArray()

itemsToArray(  $items,   $sep = ',') : array

Convert a whatever separated list of items and returns an array of them.

Parameters

$items
$sep

Returns

array —

Items.

runExternal()

runExternal(  $cmd,   $code) : mixed

Run an external program capturing both stdout and stderr.

Parameters

$cmd
$code

Returns

mixed —

false in case of error or output string

urlsafe_b64encode()

urlsafe_b64encode(  $string) 

URL safe base 64 encoding.

Compatible with python base64's urlsafe methods.

Parameters

$string

urlsafe_b64decode()

urlsafe_b64decode(  $string) 

URL safe base 64 decoding.

Parameters

$string

flattenArray()

flattenArray(array  $array) : array

Flatten an array.

Parameters

array $array

The array to flatten.

Returns

array