BodyNormalizer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
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 normalize() 0 12 4
1
<?php
2
3
/*
4
 * This file is part of the Ivory Http Adapter package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\HttpAdapter\Normalizer;
13
14
use Ivory\HttpAdapter\Asset\AbstractUninstantiableAsset;
15
use Ivory\HttpAdapter\Message\RequestInterface;
16
17
/**
18
 * @author GeLo <[email protected]>
19
 */
20
class BodyNormalizer extends AbstractUninstantiableAsset
21
{
22
    /**
23
     * @param mixed  $body
24
     * @param string $method
25
     *
26
     * @return mixed
27
     */
28 12213
    public static function normalize($body, $method)
29
    {
30 12213
        if ($method === RequestInterface::METHOD_HEAD || empty($body)) {
31 1227
            return;
32
        }
33
34 11286
        if (is_callable($body)) {
35 6084
            return call_user_func($body);
36
        }
37
38 5202
        return $body;
39
    }
40
}
41