Skip to content

Commit

Permalink
Release version 2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hungnguyenhp committed Sep 25, 2021
1 parent 0b6f285 commit 549e0a1
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 174 deletions.
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ echo "\n setLoggerSubPath: " . $debug->getLoggerSubPath() . "\n";
echo "\n setLoggerFilename: " . $debug->getLoggerFilename() . "\n";
echo "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";

dump($debug->debug($name, $msg . ' - DEBUG', $context));
dump($debug->info($name, $msg . ' - INFO', $context));
dump($debug->notice($name, $msg . ' - NOTICE', $context));
dump($debug->warning($name, $msg . ' - WARNING', $context));
dump($debug->error($name, $msg . ' - ERROR', $context));
dump($debug->critical($name, $msg . ' - CRITICAL', $context));
dump($debug->alert($name, $msg . ' - ALERT', $context));
dump($debug->emergency($name, $msg . ' - EMERGENCY', $context));
d($debug->debug($name, $msg . ' - DEBUG', $context));
d($debug->info($name, $msg . ' - INFO', $context));
d($debug->notice($name, $msg . ' - NOTICE', $context));
d($debug->warning($name, $msg . ' - WARNING', $context));
d($debug->error($name, $msg . ' - ERROR', $context));
d($debug->critical($name, $msg . ' - CRITICAL', $context));
d($debug->alert($name, $msg . ' - ALERT', $context));
d($debug->emergency($name, $msg . ' - EMERGENCY', $context));
```

### Benchmark
Expand All @@ -93,12 +93,12 @@ for ($i = 0; $i < $count; $i++) {
$function($i);
echo ($key + 1) . " -> " . $function . "\n";
}
}q
}
$benchmark->mark('code_end');

dump($benchmark->getVersion());
dump($benchmark->elapsed_time('code_start', 'code_end'));
dump($benchmark->memory_usage());
d($benchmark->getVersion());
d($benchmark->elapsed_time('code_start', 'code_end'));
d($benchmark->memory_usage());
/***************************** SIMPLE BENCHMARKING BY CI *****************************/
```

Expand All @@ -114,11 +114,11 @@ use nguyenanhung\MyDebug\Manager\File;
$file = new File();
$file->setExclude(['*.zip']);
$file->setInclude(['*.log']);
dump($file->getVersion());
d($file->getVersion());

$path = testLogPath();

dump($file->cleanLog($path, 7));
d($file->cleanLog($path, 7));
```

### Utils
Expand All @@ -133,9 +133,9 @@ use nguyenanhung\MyDebug\Utils;
$utils = new Utils();
$str = 'Nguyễn An Hưng';

dump($utils->getVersion()); // show "2.0.5"
dump($utils::slugify($str)); // show "nguyen-an-hung"
dump($utils::convert_vi_to_en($str)); // show "nguyen-an-hung"
d($utils->getVersion()); // show "2.0.5"
d($utils::slugify($str)); // show "nguyen-an-hung"
d($utils::convert_vi_to_en($str)); // show "nguyen-an-hung"
```

## Support
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
}
],
"require": {
"php": "^5.6 || ^7.0 || ^8.0",
"php": ">=5.6",
"ext-json": "*",
"ext-mbstring": "*",
"nguyenanhung/benchmark": "^1.0",
"nguyenanhung/filesystem-helper": "^1.0",
"monolog/monolog": "^2.0 || ^1.26",
"cocur/slugify": "^4.0 || ^3.0"
"nguyenanhung/slug-helper": "^1.0",
"monolog/monolog": "^2.0 || ^1.26"
},
"require-dev": {
"kint-php/kint": ">=3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
interface Project
{
const VERSION = '3.0.4';
const VERSION = '2.1.2';

/**
* Hàm lấy thông tin phiên bản Packages
Expand Down
68 changes: 0 additions & 68 deletions src/Repository/DataRepository.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/Repository/config/convert_vi_to_en.php

This file was deleted.

62 changes: 3 additions & 59 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,67 +32,13 @@ class Utils implements Project
*
* @param string $str Chuỗi ký tự đầu vào
*
* @return mixed|null|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($str = '')
{
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 mixed|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($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);
}
}
2 changes: 1 addition & 1 deletion test/test_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

d($utils->getVersion());
d($utils::slugify($str));
d($utils::convert_vi_to_en($str));

0 comments on commit 549e0a1

Please sign in to comment.