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.

Trim   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 66
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A trim() 0 6 1
A trimLeft() 0 4 1
A trimRight() 0 4 1
A getTrimChars() 0 11 2
1
<?php namespace Gears\String\Methods;
2
////////////////////////////////////////////////////////////////////////////////
3
// __________ __             ________                   __________
4
// \______   \  |__ ______  /  _____/  ____ _____ ______\______   \ _______  ___
5
//  |     ___/  |  \\____ \/   \  ____/ __ \\__  \\_  __ \    |  _//  _ \  \/  /
6
//  |    |   |   Y  \  |_> >    \_\  \  ___/ / __ \|  | \/    |   (  <_> >    <
7
//  |____|   |___|  /   __/ \______  /\___  >____  /__|  |______  /\____/__/\_ \
8
//                \/|__|           \/     \/     \/             \/            \/
9
// -----------------------------------------------------------------------------
10
//          Designed and Developed by Brad Jones <brad @="bjc.id.au" />
11
// -----------------------------------------------------------------------------
12
////////////////////////////////////////////////////////////////////////////////
13
14
use voku\helper\UTF8;
15
16
trait Trim
17
{
18
    /**
19
     * Removes whitespace from the start and end of the string.
20
     *
21
     * Supports the removal of unicode whitespace.
22
     * Accepts an optional string of characters to
23
     * strip instead of the defaults.
24
     *
25
     * @param  string|null $chars Optional string of characters to strip.
26
     *
27
     * @return static
28
     */
29
    public function trim($chars = null)
30
    {
31
        $chars = $this->getTrimChars($chars);
32
33
        return $this->regexReplace("^[$chars]+|[$chars]+\$", '');
34
    }
35
36
    /**
37
     * Returns a string with whitespace removed from the start of the string.
38
     * Supports the removal of unicode whitespace. Accepts an optional
39
     * string of characters to strip instead of the defaults.
40
     *
41
     * @param  string|null $chars Optional string of characters to strip.
42
     *
43
     * @return static
44
     */
45
    public function trimLeft($chars = null)
46
    {
47
        return $this->regexReplace("^[".$this->getTrimChars($chars)."]+", '');
48
    }
49
50
    /**
51
     * Returns a string with whitespace removed from the end of the string.
52
     * Supports the removal of unicode whitespace. Accepts an optional
53
     * string of characters to strip instead of the defaults.
54
     *
55
     * @param  string|null $chars Optional string of characters to strip.
56
     *
57
     * @return static
58
     */
59
    public function trimRight($chars = null)
60
    {
61
        return $this->regexReplace("[".$this->getTrimChars($chars)."]+\$", '');
62
    }
63
64
    /**
65
     * Internal helper method for trim methods.
66
     *
67
     * @param  string $chars
68
     * @return string
69
     */
70
    protected function getTrimChars($chars)
71
    {
72
        if (!$chars)
73
        {
74
            return '[:space:]';
75
        }
76
        else
77
        {
78
            return preg_quote($chars, $this->regexDelimiter);
79
        }
80
    }
81
}
82