Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
PSDI Army
yii2
Commits
e4e18710
Commit
e4e18710
authored
Jun 01, 2013
by
Antonio Ramirez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix functionality, keep each function to do what it supposed to do
parent
65461683
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
3 deletions
+2
-3
Inflector.php
framework/yii/helpers/base/Inflector.php
+2
-1
InflectorTest.php
tests/unit/framework/helpers/InflectorTest.php
+0
-2
No files found.
framework/yii/helpers/base/Inflector.php
View file @
e4e18710
...
...
@@ -470,6 +470,7 @@ class Inflector
public
static
function
slug
(
$string
,
$replacement
=
'-'
)
{
$map
=
array
(
'/[^\w\s]/'
=>
' '
,
'/\\s+/'
=>
$replacement
,
'/(?<=[a-z])([A-Z])/'
=>
$replacement
.
'\\1'
,
str_replace
(
':rep'
,
preg_quote
(
$replacement
,
'/'
),
'/^[:rep]+|[:rep]+$/'
)
=>
''
...
...
@@ -512,7 +513,7 @@ class Inflector
*/
public
static
function
ascii
(
$string
)
{
$map
=
static
::
$transliteration
+
array
(
'/[^\w\s]/'
=>
' '
)
;
$map
=
static
::
$transliteration
;
return
preg_replace
(
array_keys
(
$map
),
array_values
(
$map
),
$string
);
}
}
tests/unit/framework/helpers/InflectorTest.php
View file @
e4e18710
...
...
@@ -143,8 +143,6 @@ class InflectorTest extends TestCase
Inflector
::
ascii
(
"Perché l'erba è verde?"
,
"'"
));
$this
->
assertEquals
(
"Peux-tu m aider s il te plait"
,
Inflector
::
ascii
(
"Peux-tu m'aider s'il te plaît?"
,
"'"
));
$this
->
assertEquals
(
"Tank-efter-nu-forrn-vi-foser-dig-bort"
,
Inflector
::
slug
(
Inflector
::
ascii
(
"Tänk efter nu – förr'n vi föser dig bort"
)));
$this
->
assertEquals
(
"Custom delimiter example"
,
Inflector
::
ascii
(
"Custom`delimiter*example"
,
array
(
'*'
,
'`'
)));
}
...
...
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