-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #42 from nguyenanhung/v3.x
Release v3.x - Version 3.0.6
- Loading branch information
Showing
7 changed files
with
10 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
*/ | ||
interface Project | ||
{ | ||
const VERSION = '3.0.5'; | ||
const VERSION = '3.0.6'; | ||
|
||
/** | ||
* Hàm lấy thông tin phiên bản Packages | ||
|
@@ -29,5 +29,5 @@ interface Project | |
* @copyright: 713uk13m <[email protected]> | ||
* @time : 9/27/18 18:32 | ||
*/ | ||
public function getVersion(); | ||
public function getVersion(): string; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,9 +8,7 @@ | |
|
||
namespace nguyenanhung\MyDebug; | ||
|
||
use Exception; | ||
use Cocur\Slugify\Slugify; | ||
use nguyenanhung\MyDebug\Repository\DataRepository; | ||
use nguyenanhung\Libraries\Slug\SlugUrl; | ||
|
||
/** | ||
* Class Utils | ||
|
@@ -34,67 +32,13 @@ class Utils implements Project | |
* | ||
* @param string $str Chuỗi ký tự đầu vào | ||
* | ||
* @return array|mixed|string|string[] Đầu ra rà 1 chuỗi ký tự | ||
* @return string Đầu ra rà 1 chuỗi ký tự | ||
* @author: 713uk13m <[email protected]> | ||
* @time : 10/9/18 00:31 | ||
* | ||
*/ | ||
public static function slugify(string $str = '') | ||
public static function slugify(string $str = ''): string | ||
{ | ||
if (!class_exists(Slugify::class)) { | ||
if (function_exists('log_message')) { | ||
$message = 'Không tồn tại class Slugify'; | ||
log_message('error', $message); | ||
} | ||
|
||
return self::convert_vi_to_en($str); | ||
} | ||
try { | ||
$slugify = new Slugify(); | ||
|
||
return $slugify->slugify($str); | ||
} catch (Exception $e) { | ||
if (function_exists('log_message')) { | ||
log_message('error', 'Error Message: ' . $e->getMessage()); | ||
log_message('error', 'Error TraceAsString: ' . $e->getTraceAsString()); | ||
} | ||
|
||
return self::convert_vi_to_en($str); | ||
} | ||
} | ||
|
||
/** | ||
* Function convert_vi_to_en | ||
* | ||
* Hàm chuyển đổi ký tự từ tiếng Việt, | ||
* và các ký tự đặc biệt sang ký tự không dấu | ||
* | ||
* Sử dụng trong trường hợp class slugify nó không chạy | ||
* | ||
* @param string $str Chuỗi ký tự đầu vào | ||
* | ||
* @return array|mixed|string|string[] Đầu ra rà 1 chuỗi ký tự | ||
* @author: 713uk13m <[email protected]> | ||
* @time : 10/13/18 01:17 | ||
* | ||
*/ | ||
public static function convert_vi_to_en(string $str = '') | ||
{ | ||
$str = trim($str); | ||
$str = function_exists('mb_strtolower') ? mb_strtolower($str) : strtolower($str); | ||
$data = DataRepository::getData('convert_vi_to_en'); | ||
if (!empty($str)) { | ||
$str = str_replace($data['vn_array'], $data['en_array'], $str); | ||
$str = str_replace($data['special_array'], $data['separator'], $str); | ||
$str = str_replace(' ', $data['separator'], $str); | ||
while (strpos($str, '--') > 0) { | ||
$str = str_replace('--', $data['separator'], $str); | ||
} | ||
while (strpos($str, '--') === 0) { | ||
$str = str_replace('--', $data['separator'], $str); | ||
} | ||
} | ||
|
||
return $str; | ||
return (new SlugUrl())->slugify($str); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,4 @@ | |
|
||
d($utils->getVersion()); | ||
d($utils::slugify($str)); | ||
d($utils::convert_vi_to_en($str)); | ||
|