Completed
Push — master ( 984c1e...c9a923 )
by Karsten
03:26
created

ToString   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 21
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 12 4
1
<?php
2
/**
3
 * Created by gerk on 20.11.17 17:34
4
 */
5
6
namespace PeekAndPoke\Component\Psi\Psi\Str;
7
8
use PeekAndPoke\Component\Psi\Interfaces\UnaryFunction;
9
10
/**
11
 *
12
 *
13
 * @author Karsten J. Gerber <[email protected]>
14
 */
15
class ToString implements UnaryFunction
16
{
17
18
    /**
19
     * @param mixed $input
20
     *
21
     * @return mixed
22
     */
23 31
    public function __invoke($input)
24
    {
25 31
        if (is_scalar($input)) {
26 19
            return (string) $input;
27
        }
28
29 12
        if (is_object($input) && method_exists($input, '__toString')) {
30 3
            return (string) $input;
31
        }
32
33 9
        return '';
34
    }
35
}
36