Skip to content

Commit 08ec66c

Browse files
authored
Merge pull request #4 from vc-dhavaljoshi/master
Version upgraded
2 parents 6416f70 + 1a76621 commit 08ec66c

File tree

8 files changed

+60
-58
lines changed

8 files changed

+60
-58
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@ All notable changes to `laravel-word-refiner` will be documented in this file.
44

55
## v1.0.0 - 2019-01-08
66

7-
- Initial Release
7+
- Initial Release
8+
9+
## V2.0.0 - 2023-04-27
10+
11+
- Version Upgrade
12+
- Code Structure Improvement
13+
- ReadMe File Update

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ The Laravel Word Refiner package helps you to refine any words from your collect
99
You can install the package via composer:
1010

1111
```bash
12-
composer require viitorcloud/laravel-word-refiner
12+
composer require vcian/laravel-word-refiner
1313
```
1414

1515
After installation, You need to publish the config file for this package. This will add the file config/refiner.php, where you can add extra word which you want to deprecate from your collection data.
1616

1717
```bash
18-
php artisan vendor:publish --provider="WordRefiner\WordRefinerProvider"
18+
php artisan vendor:publish
1919
```
2020

2121
### Usage

composer.json

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
{
22
"name": "vcian/laravel-word-refiner",
3-
"description": "Word refining for laravel collection data",
3+
"description": "Word refining from laravel collection data",
44
"keywords": [
5-
"viitorcloud",
6-
"vcian",
7-
"viitorcloudtechnologies",
85
"laravel",
9-
"word-refiner"
6+
"abuse word",
7+
"moral police",
8+
"abuse",
9+
"word refiner",
10+
"violence word"
1011
],
12+
"type": "library",
1113
"license": "MIT",
1214
"authors": [
1315
{
14-
"name": "Viitor Cloud",
15-
"email": "[email protected]"
16+
"name": "Vcian - ViitorCloud",
17+
"homepage": "https://github.com/vcian",
18+
"role": "Developer"
1619
}
1720
],
1821
"autoload": {
1922
"psr-4": {
20-
"WordRefiner\\": "src/"
23+
"Vcian\\LaravelWordRefiner\\": "src/"
2124
},
2225
"files": [
2326
"src/helpers.php"
@@ -27,11 +30,11 @@
2730
"extra": {
2831
"laravel": {
2932
"providers": [
30-
"WordRefiner\\WordRefinerProvider"
33+
"Vcian\\LaravelWordRefiner\\Providers\\WordRefinerProvider"
3134
]
3235
}
3336
},
3437
"require": {
35-
"php": ">=5.4.0"
38+
"php": "^8.0"
3639
}
3740
}

config/refiner.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
// Add all refine words which you would like to refine (eliminate) from the collection data,
3+
4+
return [
5+
'offensive',
6+
'duck',
7+
'shit',
8+
'oops',
9+
];
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
namespace Vcian\LaravelWordRefiner\Providers;
4+
5+
use Illuminate\Support\ServiceProvider;
6+
7+
class WordRefinerProvider extends ServiceProvider
8+
{
9+
/**
10+
* @return void
11+
*/
12+
public function boot() : void
13+
{
14+
require_once __DIR__ .'/../../src/helpers.php';
15+
require_once __DIR__ . '/../../config/refiner.php';
16+
17+
$this->publishes([
18+
__DIR__ . '/../../config/refiner.php' => config_path('refiner.php'),
19+
], 'refiner-config');
20+
}
21+
}

src/WordRefinerProvider.php

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/config/refiner.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/helpers.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22

3+
use Illuminate\Support\Facades\Log;
4+
35
if (!function_exists('refiner')) {
46
/**
57
* @param $request
6-
* @return \Illuminate\Support\Collection
8+
* @return mixed
79
*/
8-
function refiner($request)
10+
function refiner($request) : mixed
911
{
1012
try {
1113
if (is_array($request)) {
@@ -28,7 +30,7 @@ function refiner($request)
2830
$detectWords = array_flip($detectWords);
2931

3032
foreach ($requestedString as $words) {
31-
$filterWords = rtrim(clean($words), '.');
33+
$filterWords = rtrim($words, '.');
3234

3335
if (!isset($detectWords[$filterWords])) {
3436
$filterString[] = $words;
@@ -41,8 +43,9 @@ function refiner($request)
4143
}
4244

4345
return $request;
44-
} catch (\Exception $ex) {
45-
\Log::error($ex->getMessage());
46+
} catch (Exception $ex) {
47+
Log::error($ex->getMessage());
48+
4649
return collect([]);
4750
}
4851
}

0 commit comments

Comments
 (0)