removeChar()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string.
4
 * You're given one parameter, the original string. You don't have to worry with strings with less than two characters.
5
 */
6
function removeChar(string $string)
7
{
8
    $removeFirst = substr($string, 1);
9
    $finalString = substr($removeFirst, 0, strlen($removeFirst)-1);
10
    return $finalString;
11
}
12
13
/**
14
 * Alternate solution
15
 */
16
17
function altremoveChar(string $string)
18
{
19
    return substr($string, 1, -1);
20
}
21