// SYSTEM PANEL //
[ROOT]
/
mnt
/
pleskStorage
/
vhosts
/
kodsolutions.net
/
subdomains
/
syaaraa.kodsolutions.net
/
app
/
GraphQL
/
Scalars
[ PARENT ]
EDIT :: JSON.php
<?php declare(strict_types=1); namespace App\GraphQL\Scalars; use GraphQL\Language\AST\BooleanValueNode; use GraphQL\Language\AST\FloatValueNode; use GraphQL\Language\AST\IntValueNode; use GraphQL\Language\AST\ListValueNode; use GraphQL\Language\AST\ObjectValueNode; use GraphQL\Language\AST\StringValueNode; use GraphQL\Type\Definition\ScalarType; class JSON extends ScalarType { public $description = 'The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).'; /** * Serializes an internal value to include in a response. * * @param mixed $value * @return mixed */ public function serialize($value) { // Assuming the internal representation of the value is always correct return $value; } /** * Parses an externally provided value (query variable) to use as an input. * * @param mixed $value * @return mixed */ public function parseValue($value) { return $value; } /** * Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input. * * E.g. * { * user(email: "user@example.com") * } * * @param \GraphQL\Language\AST\Node $valueNode * @param mixed[]|null $variables * @return mixed */ public function parseLiteral($valueNode, ?array $variables = null) { switch ($valueNode) { case $valueNode instanceof StringValueNode: case $valueNode instanceof BooleanValueNode: return $valueNode->value; case $valueNode instanceof IntValueNode: case $valueNode instanceof FloatValueNode: return floatval($valueNode->value); case $valueNode instanceof ObjectValueNode: $value = []; foreach ($valueNode->fields as $field) { $value[$field->name->value] = $this->parseLiteral($field->value); } return $value; case $valueNode instanceof ListValueNode: return array_map([$this, 'parseLiteral'], $valueNode->values); default: return null; } } }
SAVE
CANCEL