Completed
Push — master ( 463d73...47ba96 )
by Gerrit
02:04
created

RequestPayloadArgument   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 46.43 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 13
loc 28
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolve() 13 13 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Copyright (C) 2018 Gerrit Addiks.
4
 * This package (including this file) was released under the terms of the GPL-3.0.
5
 * You should have received a copy of the GNU General Public License along with this program.
6
 * If not, see <http://www.gnu.org/licenses/> or send me a mail so i can send you a copy.
7
 *
8
 * @license GPL-3.0
9
 *
10
 * @author Gerrit Addiks <[email protected]>
11
 */
12
13
namespace Addiks\SymfonyGenerics\Arguments;
14
15
use Addiks\SymfonyGenerics\Arguments\Argument;
16
use Symfony\Component\HttpFoundation\RequestStack;
17
use Symfony\Component\HttpFoundation\Request;
18
use Webmozart\Assert\Assert;
19
20
final class RequestPayloadArgument implements Argument
21
{
22
23
    /**
24
     * @var RequestStack
25
     */
26
    private $requestStack;
27
28 2
    public function __construct(RequestStack $requestStack)
29
    {
30 2
        $this->requestStack = $requestStack;
31 2
    }
32
33 2 View Code Duplication
    public function resolve()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        /** @var Request $request */
36 2
        $request = $this->requestStack->getCurrentRequest();
37
38 2
        Assert::isInstanceOf(
39 2
            $request,
40 2
            Request::class,
41 2
            "Cannot resolve request-argument without active request!"
42
        );
43
44 1
        return $request->getContent(false);
45
    }
46
47
}
48