Concat::transform()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
c 1
b 0
f 0
ccs 6
cts 6
cp 1
rs 9.2
nc 3
cc 4
eloc 6
nop 2
crap 4
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\TransformationException;
20
21
/**
22
 * Concat strings
23
 */
24
class Concat extends AbstractRule
25
{
26
    /**
27
     * Operate the transformation
28
     *
29
     * @param string $input
30
     * @param array  $arguments
31
     *
32
     * @throws Inet\Transformation\Exception\TransformationException
33
     *
34
     * @return string
35
     */
36 4
    public function transform($input, array $arguments)
37
    {
38
        // I should have two arguments: old format / new format
39 4
        if (count($arguments) !== 1 && count($arguments) !== 2) {
40 2
            throw new TransformationException('Rule Concat Expects 1 or 2 argument(s)');
41
        }
42 2
        $before = $arguments[0];
43 2
        $after = (array_key_exists(1, $arguments) ? $arguments[1] : '');
44
45 2
        return $before.$input.$after;
46
    }
47
}
48