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.

TextUtils::parseBoolean()   C
last analyzed

Complexity

Conditions 7
Paths 7

Size

Total Lines 30
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 25.4573
Metric Value
dl 0
loc 30
ccs 5
cts 18
cp 0.2778
rs 6.7272
cc 7
eloc 18
nc 7
nop 1
crap 25.4573
1
<?php
2
/**
3
 * @link https://github.com/old-town/old-town-workflow
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Util;
7
8
/**
9
 * Class TextUtil
10
 * @package OldTown\Workflow\Util
11
 */
12
class  TextUtils
13
{
14
    /**
15
     * @param $in
16
     * @return bool|string
17
     */
18 11
    public static function parseBoolean($in)
19
    {
20 11
        $value = $in;
21 11
        if (!is_string($value)) {
22 11
            if (!settype($value, 'boolean')) {
23
                return false;
24
            }
25 11
            return $value;
26
        }
27
28
        $value = trim($value);
29
        if (0 === count($value)) {
30
            return false;
31
        }
32
33
        $firstSymbol = substr($value, 0, 1);
34
        $firstSymbol = strtolower($firstSymbol);
35
36
        switch ($firstSymbol) {
37
            case '1':
38
            case 't':
39
            case 'y': {
40
                return true;
41
            }
42
            default: {
43
                return false;
44
            }
45
46
        }
47
    }
48
}
49