DefaultStringConverter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 26
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A convert() 0 17 5
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
7
declare(strict_types=1);
8
9
namespace Tebru\Retrofit\Internal\Converter;
10
11
use Tebru\Retrofit\StringConverter;
12
13
/**
14
 * Class DefaultStringConverter
15
 *
16
 * @author Nate Brunette <[email protected]>
17
 */
18
final class DefaultStringConverter implements StringConverter
19
{
20
    /**
21
     * Convert any supported value to a string
22
     *
23
     * @param mixed $value
24
     * @return string
25
     */
26 27
    public function convert($value): string
27
    {
28
        // if it's an array or object, just serialize it
29 27
        if (\is_array($value) || \is_object($value)) {
30 2
            return serialize($value);
31
        }
32
33 25
        if ($value === true) {
34 4
            return 'true';
35
        }
36
37 24
        if ($value === false) {
38 5
            return 'false';
39
        }
40
41 23
        return (string)$value;
42
    }
43
}
44