Code Duplication    Length = 41-41 lines in 2 locations

src/RequestModifierCollection.php 1 location

@@ 13-53 (lines=41) @@
10
 * @package Thruster\Component\HttpModifier
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class RequestModifierCollection extends BaseModifierCollection implements RequestModifierInterface
14
{
15
    /**
16
     * @param RequestModifierInterface[] $modifiers
17
     */
18
    public function __construct(array $modifiers = [])
19
    {
20
        parent::__construct();
21
22
        $this->collection = (function (RequestModifierInterface ...$modifiers) {
23
            return $modifiers;
24
        })(...$modifiers);
25
    }
26
27
    /***
28
     * @param RequestModifierInterface $modifier
29
     *
30
     * @return $this
31
     */
32
    public function add(RequestModifierInterface $modifier)
33
    {
34
        $this->collection[] = $modifier;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param RequestInterface $request
41
     *
42
     * @return RequestInterface
43
     */
44
    public function modify(RequestInterface $request) : RequestInterface
45
    {
46
        /** @var RequestModifierInterface $modifier */
47
        foreach ($this->collection as $modifier) {
48
            $request = $modifier->modify($request);
49
        }
50
51
        return $request;
52
    }
53
}
54

src/ServerRequestModifierCollection.php 1 location

@@ 13-53 (lines=41) @@
10
 * @package Thruster\Component\HttpModifier
11
 * @author  Aurimas Niekis <[email protected]>
12
 */
13
class ServerRequestModifierCollection extends BaseModifierCollection implements ServerRequestModifierInterface
14
{
15
    /**
16
     * @param ServerRequestModifierInterface[] $modifiers
17
     */
18
    public function __construct(array $modifiers = [])
19
    {
20
        parent::__construct();
21
22
        $this->collection = (function (ServerRequestModifierInterface ...$modifiers) {
23
            return $modifiers;
24
        })(...$modifiers);
25
    }
26
27
    /***
28
     * @param ServerRequestModifierInterface $modifier
29
     *
30
     * @return $this
31
     */
32
    public function add(ServerRequestModifierInterface $modifier)
33
    {
34
        $this->collection[] = $modifier;
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param ServerRequestInterface $request
41
     *
42
     * @return ServerRequestInterface
43
     */
44
    public function modify(ServerRequestInterface $request) : ServerRequestInterface
45
    {
46
        /** @var ServerRequestModifierInterface $modifier */
47
        foreach ($this->collection as $modifier) {
48
            $request = $modifier->modify($request);
49
        }
50
51
        return $request;
52
    }
53
}
54