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.

Remove   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 53.73 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A removeLeft() 18 18 2
A removeRight() 18 18 2
A removeWhitespace() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 Remove
17
{
18
    /**
19
     * Returns a new string with the prefix $substring removed, if present.
20
     *
21
     * @param  string $substring The prefix to remove.
22
     *
23
     * @return static            String without the prefix $substring.
24
     */
25 View Code Duplication
    public function removeLeft($substring)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        if ($this->startsWith($substring))
28
        {
29
            return $this->newSelf
30
            (
31
                UTF8::substr
32
                (
33
                    $this->scalarString,
34
                    UTF8::strlen($substring, $this->encoding),
35
                    null,
36
                    $this->encoding
37
                )
38
            );
39
        }
40
41
        return $this;
42
    }
43
44
    /**
45
     * Returns a new string with the suffix $substring removed, if present.
46
     *
47
     * @param  string $substring The suffix to remove.
48
     *
49
     * @return static            String without the suffix $substring.
50
     */
51 View Code Duplication
    public function removeRight($substring)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        if ($this->endsWith($substring))
54
        {
55
            return $this->newSelf
56
            (
57
                UTF8::substr
58
                (
59
                    $this->scalarString,
60
                    0,
61
                    $this->getLength() - UTF8::strlen($substring, $this->encoding),
62
                    $this->encoding
63
                )
64
            );
65
        }
66
67
        return $this;
68
    }
69
70
    /**
71
     * Trims and replaces consecutive whitespace characters with a single space.
72
     *
73
     * This includes tabs and newline characters, as well as multibyte
74
     * whitespace such as the thin space and ideographic space.
75
     *
76
     * @return static Trimmed and condensed whitespace.
77
     */
78
    public function removeWhitespace()
79
    {
80
        return $this->regexReplace('[[:space:]]+', ' ')->trim();
81
    }
82
}
83