Code Duplication    Length = 28-33 lines in 5 locations

src/TreeHouse/Feeder/Modifier/Data/Transformer/CallbackTransformer.php 1 location

@@ 7-35 (lines=29) @@
4
5
use TreeHouse\Feeder\Exception\UnexpectedTypeException;
6
7
class CallbackTransformer implements TransformerInterface
8
{
9
    /**
10
     * @var callable
11
     */
12
    protected $callback;
13
14
    /**
15
     * @param callable $callback
16
     *
17
     * @throws UnexpectedTypeException
18
     */
19
    public function __construct($callback)
20
    {
21
        if (!is_callable($callback)) {
22
            throw new UnexpectedTypeException($callback, 'callback');
23
        }
24
25
        $this->callback = $callback;
26
    }
27
28
    /**
29
     * @inheritdoc
30
     */
31
    public function transform($value)
32
    {
33
        return call_user_func($this->callback, $value);
34
    }
35
}
36

src/TreeHouse/Feeder/Modifier/Item/Filter/CallbackFilter.php 1 location

@@ 8-38 (lines=31) @@
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
use TreeHouse\Feeder\Exception\UnexpectedTypeException;
7
8
class CallbackFilter implements FilterInterface
9
{
10
    /**
11
     * @var callable
12
     */
13
    protected $callback;
14
15
    /**
16
     * Constructor.
17
     *
18
     * @param callable $callback
19
     *
20
     * @throws UnexpectedTypeException
21
     */
22
    public function __construct($callback)
23
    {
24
        if (!is_callable($callback)) {
25
            throw new UnexpectedTypeException($callback, 'callback');
26
        }
27
28
        $this->callback = $callback;
29
    }
30
31
    /**
32
     * @inheritdoc
33
     */
34
    public function filter(ParameterBag $item)
35
    {
36
        return call_user_func($this->callback, $item);
37
    }
38
}
39

src/TreeHouse/Feeder/Modifier/Item/Transformer/CallbackTransformer.php 1 location

@@ 8-36 (lines=29) @@
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
use TreeHouse\Feeder\Exception\UnexpectedTypeException;
7
8
class CallbackTransformer implements TransformerInterface
9
{
10
    /**
11
     * @var callable
12
     */
13
    protected $callback;
14
15
    /**
16
     * @param callable $callback
17
     *
18
     * @throws UnexpectedTypeException
19
     */
20
    public function __construct($callback)
21
    {
22
        if (!is_callable($callback)) {
23
            throw new UnexpectedTypeException($callback, 'callback');
24
        }
25
26
        $this->callback = $callback;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     */
32
    public function transform(ParameterBag $item)
33
    {
34
        call_user_func($this->callback, $item);
35
    }
36
}
37

src/TreeHouse/Feeder/Modifier/Item/Validator/CallbackValidator.php 1 location

@@ 8-35 (lines=28) @@
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
use TreeHouse\Feeder\Exception\UnexpectedTypeException;
7
8
class CallbackValidator implements ValidatorInterface
9
{
10
    /**
11
     * @var callable
12
     */
13
    protected $callback;
14
15
    /**
16
     * Constructor.
17
     *
18
     * @param callable $callback
19
     *
20
     * @throws UnexpectedTypeException
21
     */
22
    public function __construct($callback)
23
    {
24
        if (!is_callable($callback)) {
25
            throw new UnexpectedTypeException($callback, 'callback');
26
        }
27
28
        $this->callback = $callback;
29
    }
30
31
    public function validate(ParameterBag $item)
32
    {
33
        return call_user_func($this->callback, $item);
34
    }
35
}
36

src/TreeHouse/Feeder/Transport/Matcher/CallbackMatcher.php 1 location

@@ 7-39 (lines=33) @@
4
5
use TreeHouse\Feeder\Exception\UnexpectedTypeException;
6
7
class CallbackMatcher implements MatcherInterface
8
{
9
    /**
10
     * @var callable
11
     */
12
    protected $callback;
13
14
    /**
15
     * Constructor.
16
     *
17
     * @param callable $callback
18
     *
19
     * @throws UnexpectedTypeException
20
     */
21
    public function __construct($callback)
22
    {
23
        if (!is_callable($callback)) {
24
            throw new UnexpectedTypeException($callback, 'callback');
25
        }
26
27
        $this->callback = $callback;
28
    }
29
30
    public function match(array $files)
31
    {
32
        return call_user_func($this->callback, $files);
33
    }
34
35
    public function __toString()
36
    {
37
        return 'callback';
38
    }
39
}
40