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.

CaseFormatter   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 3
dl 0
loc 34
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A camelToColon() 0 4 1
A colonToCamel() 0 4 1
A dashToCamel() 0 4 1
A camelToDash() 0 4 1
A dashToCamelArray() 0 6 1
A stringToBool() 0 4 3
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the "php-ipfs" package.
7
 *
8
 * (c) Robert Schönthal <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace IPFS\Utils;
15
16
use Camel\CaseTransformer;
17
use Camel\Format\CamelCase;
18
19
class CaseFormatter
20
{
21 5
    public static function camelToColon($value)
22
    {
23 5
        return (new CaseTransformer(new CamelCase(), new ConfigurableFormatter(':')))->transform($value);
24
    }
25
26 1
    public static function colonToCamel($value)
27
    {
28 1
        return (new CaseTransformer(new ConfigurableFormatter(':'), new CamelCase()))->transform($value);
29
    }
30
31 5
    public static function dashToCamel($value)
32
    {
33 5
        return (new CaseTransformer(new ConfigurableFormatter('-'), new CamelCase()))->transform($value);
34
    }
35
36 4
    public static function camelToDash($value)
37
    {
38 4
        return (new CaseTransformer(new CamelCase(), new ConfigurableFormatter('-')))->transform($value);
39
    }
40
41
    public static function dashToCamelArray(array $values): array
42
    {
43 2
        return array_combine(array_map(function ($name) {
44 2
            return self::dashToCamel($name);
45 2
        }, array_keys($values)), array_values($values));
46
    }
47
48 3
    public static function stringToBool($value)
49
    {
50 3
        return is_string($value) && in_array(strtolower($value), ['true', 'false'], true) ? filter_var($value, FILTER_VALIDATE_BOOLEAN) : $value;
51
    }
52
}
53