Implode   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 17 3
1
<?php
2
/**
3
 * inetprocess/transformation
4
 *
5
 * PHP Version 5.3
6
 *
7
 * @author Emmanuel Dyan
8
 * @copyright 2005-2015 iNet Process
9
 *
10
 * @package inetprocess/transformation
11
 *
12
 * @license GNU General Public License v2.0
13
 *
14
 * @link http://www.inetprocess.com
15
 */
16
17
namespace Inet\Transformation\Rule;
18
19
use Inet\Transformation\Exception\NotTransformableException;
20
use Inet\Transformation\Exception\TransformationException;
21
22
/**
23
 * Implode an array (useful after a callback)
24
 */
25
class Implode extends AbstractRule
26
{
27
    /**
28
     * Operate the transformation
29
     *
30
     * @param string $input
31
     * @param array  $arguments
32
     *
33
     * @throws Inet\Transformation\Exception\TransformationException
34
     *
35
     * @return string
36
     */
37 6
    public function transform($input, array $arguments)
38
    {
39
        // I should have two arguments: old format / new format
40 6
        if (count($arguments) !== 1) {
41 2
            throw new TransformationException('Rule Implode Expects exactly 1 argument');
42
        }
43
44 4
        if (!is_array($input)) {
45 1
            throw new NotTransformableException('Rule Implode can transform an array. '
46 1
                . gettype($input).' found in input');
47
        }
48
49
        // Transform it
50 3
        $output = implode($arguments[0], $input);
51
52 3
        return $output;
53
    }
54
}
55