Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
6f847732
Commit
6f847732
authored
Aug 08, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert spaces to tabs.
parent
4465c027
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
89 deletions
+89
-89
str.php
system/str.php
+89
-89
No files found.
system/str.php
View file @
6f847732
...
@@ -10,107 +10,107 @@ class Str {
...
@@ -10,107 +10,107 @@ class Str {
*/
*/
public
static
function
entities
(
$value
)
public
static
function
entities
(
$value
)
{
{
return
htmlentities
(
$value
,
ENT_QUOTES
,
Config
::
get
(
'application.encoding'
),
false
);
return
htmlentities
(
$value
,
ENT_QUOTES
,
Config
::
get
(
'application.encoding'
),
false
);
}
}
/**
/**
* Convert a string to lowercase.
* Convert a string to lowercase.
*
*
* @param string $value
* @param string $value
* @return string
* @return string
*/
*/
public
static
function
lower
(
$value
)
public
static
function
lower
(
$value
)
{
{
return
function_exists
(
'mb_strtolower'
)
?
mb_strtolower
(
$value
,
Config
::
get
(
'application.encoding'
))
:
strtolower
(
$value
);
return
function_exists
(
'mb_strtolower'
)
?
mb_strtolower
(
$value
,
Config
::
get
(
'application.encoding'
))
:
strtolower
(
$value
);
}
}
/**
/**
* Convert a string to uppercase.
* Convert a string to uppercase.
*
*
* @param string $value
* @param string $value
* @return string
* @return string
*/
*/
public
static
function
upper
(
$value
)
public
static
function
upper
(
$value
)
{
{
return
function_exists
(
'mb_strtoupper'
)
?
mb_strtoupper
(
$value
,
Config
::
get
(
'application.encoding'
))
:
strtoupper
(
$value
);
return
function_exists
(
'mb_strtoupper'
)
?
mb_strtoupper
(
$value
,
Config
::
get
(
'application.encoding'
))
:
strtoupper
(
$value
);
}
}
/**
/**
* Convert a string to title case (ucwords).
* Convert a string to title case (ucwords).
*
*
* @param string $value
* @param string $value
* @return string
* @return string
*/
*/
public
static
function
title
(
$value
)
public
static
function
title
(
$value
)
{
{
return
(
function_exists
(
'mb_convert_case'
))
?
mb_convert_case
(
$value
,
MB_CASE_TITLE
,
Config
::
get
(
'application.encoding'
))
:
ucwords
(
strtolower
(
$value
));
return
(
function_exists
(
'mb_convert_case'
))
?
mb_convert_case
(
$value
,
MB_CASE_TITLE
,
Config
::
get
(
'application.encoding'
))
:
ucwords
(
strtolower
(
$value
));
}
}
/**
/**
* Get the length of a string.
* Get the length of a string.
*
*
* @param string $value
* @param string $value
* @return int
* @return int
*/
*/
public
static
function
length
(
$value
)
public
static
function
length
(
$value
)
{
{
return
function_exists
(
'mb_strlen'
)
?
mb_strlen
(
$value
,
Config
::
get
(
'application.encoding'
))
:
strlen
(
$value
);
return
function_exists
(
'mb_strlen'
)
?
mb_strlen
(
$value
,
Config
::
get
(
'application.encoding'
))
:
strlen
(
$value
);
}
}
/**
/**
* Convert a string to 7-bit ASCII.
* Convert a string to 7-bit ASCII.
*
*
* @param string $value
* @param string $value
* @return string
* @return string
*/
*/
public
static
function
ascii
(
$value
)
public
static
function
ascii
(
$value
)
{
{
$foreign
=
Config
::
get
(
'ascii'
);
$foreign
=
Config
::
get
(
'ascii'
);
$value
=
preg_replace
(
array_keys
(
$foreign
),
array_values
(
$foreign
),
$value
);
$value
=
preg_replace
(
array_keys
(
$foreign
),
array_values
(
$foreign
),
$value
);
return
preg_replace
(
'/[^\x09\x0A\x0D\x20-\x7E]/'
,
''
,
$value
);
return
preg_replace
(
'/[^\x09\x0A\x0D\x20-\x7E]/'
,
''
,
$value
);
}
}
/**
/**
* Generate a random alpha or alpha-numeric string.
* Generate a random alpha or alpha-numeric string.
*
*
* Supported types: 'alpha_num' and 'alpha'.
* Supported types: 'alpha_num' and 'alpha'.
*
*
* @param int
$length
* @param int
$length
* @param string $type
* @param string $type
* @return string
* @return string
*/
*/
public
static
function
random
(
$length
=
16
,
$type
=
'alpha_num'
)
public
static
function
random
(
$length
=
16
,
$type
=
'alpha_num'
)
{
{
$value
=
''
;
$value
=
''
;
$pool_length
=
strlen
(
$pool
=
static
::
pool
(
$type
))
-
1
;
$pool_length
=
strlen
(
$pool
=
static
::
pool
(
$type
))
-
1
;
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
{
{
$value
.=
$pool
[
mt_rand
(
0
,
$pool_length
)];
$value
.=
$pool
[
mt_rand
(
0
,
$pool_length
)];
}
}
return
$value
;
return
$value
;
}
}
/**
/**
* Get a chracter pool.
* Get a chracter pool.
*
*
* @param string $type
* @param string $type
* @return string
* @return string
*/
*/
private
static
function
pool
(
$type
=
'alpha_num'
)
private
static
function
pool
(
$type
=
'alpha_num'
)
{
{
switch
(
$type
)
switch
(
$type
)
{
{
case
'alpha_num'
:
case
'alpha_num'
:
return
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
return
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
default
:
default
:
return
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
return
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
}
}
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment