Completed
Push — master ( 9e9a0d...740d0f )
by Rafael
04:13
created

AddNode::prePersist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/*******************************************************************************
3
 *  This file is part of the GraphQL Bundle package.
4
 *
5
 *  (c) YnloUltratech <[email protected]>
6
 *
7
 *  For the full copyright and license information, please view the LICENSE
8
 *  file that was distributed with this source code.
9
 ******************************************************************************/
10
11
namespace Ynlo\GraphQLBundle\Mutation;
12
13
use Ynlo\GraphQLBundle\Extension\ExtensionManager;
14
use Ynlo\GraphQLBundle\Model\AddNodePayload;
15
use Ynlo\GraphQLBundle\Model\NodeInterface;
16
use Ynlo\GraphQLBundle\Validator\ConstraintViolationList;
17
18
/**
19
 * Class AddNode
20
 */
21
class AddNode extends AbstractMutationResolver
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 4 View Code Duplication
    protected function process(&$data)
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...
27
    {
28 4
        $this->prePersist($data);
29 4
        foreach ($this->container->get(ExtensionManager::class)->getExtensions() as $extension) {
30
            $extension->prePersist($data, $this, $this->context);
31
        }
32
33 4
        $this->getManager()->persist($data);
34 4
        $this->getManager()->flush();
35
36 4
        $this->postPersist($data);
37 4
        foreach ($this->container->get(ExtensionManager::class)->getExtensions() as $extension) {
38
            $extension->postPersist($data, $this, $this->context);
39
        }
40 4
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 5 View Code Duplication
    protected function returnPayload($data, ConstraintViolationList $violations, $inputSource)
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...
46
    {
47 5
        if ($violations->count()) {
48 1
            $data = null;
49
        }
50
51 5
        return new AddNodePayload($data, $violations->all(), $inputSource['clientMutationId'] ?? null);
52
    }
53
54
    /**
55
     * @param NodeInterface $node
56
     */
57 4
    protected function prePersist(NodeInterface $node)
0 ignored issues
show
Unused Code introduced by
The parameter $node is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

57
    protected function prePersist(/** @scrutinizer ignore-unused */ NodeInterface $node)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
58
    {
59
        //override
60 4
    }
61
62
    /**
63
     * @param NodeInterface $node
64
     */
65 4
    protected function postPersist(NodeInterface $node)
0 ignored issues
show
Unused Code introduced by
The parameter $node is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

65
    protected function postPersist(/** @scrutinizer ignore-unused */ NodeInterface $node)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    {
67
        //override
68 4
    }
69
}
70