AddNode::prePersist()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 0
dl 0
loc 2
c 0
b 0
f 0
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
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\Model\NodeInterface;
14
use Ynlo\GraphQLBundle\Validator\ConstraintViolationList;
15
16
/**
17
 * Class AddNode
18
 */
19
class AddNode extends AbstractMutationResolver
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public function process(&$data)
25
    {
26
        $this->prePersist($data);
27
        foreach ($this->extensions as $extension) {
28
            $extension->prePersist($data, $this, $this->context);
29
        }
30
31
        $this->getManager()->persist($data);
32
        $this->getManager()->flush();
33
34
        $this->postPersist($data);
35
        foreach ($this->extensions as $extension) {
36
            $extension->postPersist($data, $this, $this->context);
37
        }
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function returnPayload($data, ConstraintViolationList $violations, $inputSource)
44
    {
45
        if ($violations->count()) {
46
            $data = null;
47
        }
48
49
        $class = $this->getPayloadClass();
50
51
        return new $class($data, $violations->all(), $inputSource['clientMutationId'] ?? null);
52
    }
53
54
    /**
55
     * @param NodeInterface $node
56
     */
57
    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
    }
61
62
    /**
63
     * @param NodeInterface $node
64
     */
65
    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
    }
69
}
70