GatewayFactory::factory()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
namespace Elastification\Client\Serializer\Gateway;
3
4
/**
5
 * @package Elastification\Client\Serializer\Gateway
6
 * @author  Mario Mueller
7
 */
8
abstract class GatewayFactory
9
{
10
    /**
11
     * @param mixed $value
12
     *
13
     * @return GatewayInterface|mixed
14
     * @author Mario Mueller
15
     */
16 276
    public static function factory($value)
17
    {
18 276
        if (is_array($value)) {
19 94
            return new NativeArrayGateway($value);
20 199
        } elseif (is_object($value)) {
21 11
            return new NativeObjectGateway($value);
22
        }
23
24 193
        return $value;
25
    }
26
}
27