Passed
Push — main ( 1a7f0e...7d39cf )
by Oscar
03:17
created

is_string()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
/*
4
 * This file is part of ocubom/twig-svg-extension
5
 *
6
 * © Oscar Cubo Medina <https://ocubom.github.io>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ocubom\Twig\Extension;
13
14
/**
15
 * Find whether the type of a variable is string or it can be converted to a string.
16
 *
17
 * @see https://php.net/manual/function.is-string.php
18
 *
19
 * @param mixed $value the variable being evaluated
20
 *
21
 * @return bool true if value is of type string or convertible, false otherwise
22
 *
23
 * @psalm-assert-if-true string $value
24
 */
25
function is_string($value): bool
26
{
27 7
    return \is_string($value)
28 7
        || (is_object($value) && method_exists($value, '__toString'));
29
}
30