ynloultratech /
graphql-bundle
| 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
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
|
|||
| 42 | } |
||
| 43 | } |
||
| 44 |