IDEncoder::encode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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\Util;
12
13
use Ynlo\GraphQLBundle\Encoder\IDEncoderInterface;
14
use Ynlo\GraphQLBundle\Model\NodeInterface;
15
16
abstract class IDEncoder
17
{
18
    /**
19
     * @var IDEncoderInterface
20
     */
21
    private static $encoder;
22
23 5
    public static function setup(IDEncoderInterface $encoder)
24
    {
25 5
        self::$encoder = $encoder;
26 5
    }
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 1
    public static function encode(NodeInterface $node): ?string
32
    {
33 1
        return static::$encoder->encode($node);
0 ignored issues
show
Bug introduced by
Since $encoder is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $encoder to at least protected.
Loading history...
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 4
    public static function decode($globalId): ?NodeInterface
40
    {
41 4
        return static::$encoder->decode($globalId);
0 ignored issues
show
Bug introduced by
Since $encoder is declared private, accessing it with static will lead to errors in possible sub-classes; you can either use self, or increase the visibility of $encoder to at least protected.
Loading history...
42
    }
43
}
44