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.

FirstLast::first()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 9

Duplication

Lines 17
Ratio 100 %

Importance

Changes 0
Metric Value
dl 17
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 2
nop 1
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 FirstLast
17
{
18
    /**
19
     * Returns the first $n characters of the string.
20
     *
21
     * @param  int $n Number of characters to retrieve from the start.
22
     *
23
     * @return static String being the first $n chars.
24
     */
25 View Code Duplication
    public function first($n)
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
        $first = '';
28
29
        if ($n > 0)
30
        {
31
            $first = UTF8::substr
32
            (
33
                $this->scalarString,
34
                0,
35
                $n,
36
                $this->encoding
37
            );
38
        }
39
40
        return $this->newSelf($first);
41
    }
42
43
    /**
44
     * Returns the last $n characters of the string.
45
     *
46
     * @param  int $n Number of characters to retrieve from the end.
47
     *
48
     * @return static String being the last $n chars.
49
     */
50 View Code Duplication
    public function last($n)
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...
51
    {
52
        $last = '';
53
54
        if ($n > 0)
55
        {
56
            $last = UTF8::substr
57
            (
58
                $this->scalarString,
59
                -$n,
60
                null,
61
                $this->encoding
62
            );
63
        }
64
65
        return $this->newSelf($last);
66
    }
67
}
68