GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

CustomSlugify   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 30
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A customizeSlugEngine() 0 5 1
A slugify_th() 0 17 1
1
<?php 
2
3
namespace Raystech\StarterKit\Traits;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Collection;
7
use Illuminate\Database\Eloquent\Model;
8
use Illuminate\Database\Eloquent\Relations\MorphMany;
9
use Illuminate\Database\Query\JoinClause;
10
use Cocur\Slugify\Slugify;
11
12
trait CustomSlugify
13
{
14
15
  /*
16
   * Rerurn slug string with support TH language
17
   */
18
  private function slugify_th($string, $separator)
19
  {
20
    $string = trim($string);
21
    $string = mb_strtolower($string, 'UTF-8');
22
23
    // Make alphanumeric (removes all other characters)
24
    // this makes the string safe especially when used as a part of a URL
25
    // this keeps latin characters and Persian characters as well
26
    $string = preg_replace("/[^a-z0-9_\s-ๅภถุึคตจขชๆไำพะัีรนยบลฃฟหกดเ้่าสวงผปแอิืทมใฝูฎฑธ๊ณญฐฅฤฆฏโฌ็๋ษศซฉฮ์ฒฬฦ]/u", '', $string);
27
28
    // Remove multiple dashes or whitespaces or underscores
29
    $string = preg_replace("/[\s-_]+/", ' ', $string);
30
31
    // Convert whitespaces and underscore to the given separator
32
    $string = preg_replace("/[\s_]/", $separator, $string);
33
34
    return $string;
35
  }
36
37
  public function customizeSlugEngine(Slugify $engine, $attribute)
0 ignored issues
show
Unused Code introduced by
The parameter $attribute is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
  public function customizeSlugEngine(Slugify $engine, /** @scrutinizer ignore-unused */ $attribute)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $engine is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

37
  public function customizeSlugEngine(/** @scrutinizer ignore-unused */ Slugify $engine, $attribute)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
  {
39
    $reg_str = '/([^A-Za-z0-9ภถุึคตจขชๆไำพะัีรนยบลฃฟหกดเ้่าสวงผปแอิืทมใฝูฎฑธ๊ณญฐฅฤฆฏโฌ็๋ษศซฉฮ์ฒฬฦ]|-)+/';
40
    $engine = new Slugify(['regexp' => $reg_str]);
41
    return $engine;
42
  }
43
}