Parse a literal provided as part of a GraphQL query string into a Carbon instance.

@param  \GraphQL\Language\AST\Node  $valueNode
@param  mixed[]|null  $variables
@return \Carbon\Carbon

@throws \GraphQL\Error\Error
13477
public function parseLiteral($valueNode, ?array $variables = null): Carbon
    {
        if (! $valueNode instanceof StringValueNode) {
            throw new Error(
                "Query error: Can only parse strings, got {$valueNode->kind}",
                [$valueNode]
            );
        }

        return $this->tryParsingDate($valueNode->value, Error::class);
    }
21652
public function get($key, $defaultValue = null)
    {
        $keyExists = true;
        $parts     = $this->getPath($key);
        $node      = $this->getFromCache();

        foreach($parts as $part) {
            $part = trim($part);

            if (!is_array($node) || !array_key_exists($part, $node)) {
                $keyExists = false;
                break;
            }

            $node = &$node[$part];
        }

        if ($keyExists) {
            return $node;
        } else {
            return $defaultValue;
        }
    }
376804
public static function RAW_setGetVar($varname, $varvalue, $currentURL = null)
    {
        $url = self::setGetVar($varname, $varvalue, $currentURL);
        return Convert::xml2raw($url);
    }
446583
protected function setNodeKey(NodeValue $nodeValue): void
    {
        if ($nodeValue->getCacheKey()) {
            return;
        }

        $fields = data_get($nodeValue->getTypeDefinition(), 'fields', []);
        $nodeKey = (new Collection($fields))->reduce(function (?string $key, FieldDefinitionNode $field): ?string {
            if ($key) {
                return $key;
            }

            $hasCacheKey = (new Collection($field->directives))
                ->contains(function (DirectiveNode $directive): bool {
                    return $directive->name->value === 'cacheKey';
                });

            return $hasCacheKey
                ? $field->name->value
                : $key;
        });

        if (! $nodeKey) {
            $nodeKey = (new Collection($fields))->reduce(function (?string $key, FieldDefinitionNode $field): ?string {
                if ($key) {
                    return $key;
                }

                $typeName = ASTHelper::getUnderlyingTypeName($field);

                return $typeName === 'ID'
                    ? $field->name->value
                    : $key;
            });
        }

        if (! $nodeKey && $nodeValue->getTypeDefinitionName() !== 'Query') {
            throw new DirectiveException(
                "No @cacheKey or ID field defined on {$nodeValue->getTypeDefinitionName()}"
            );
        }

        $nodeValue->setCacheKey($nodeKey);
    }
830224
public function addNode( $nodeName, $nodeValue = false )
	{
		$newNode = new ADT_Graph_Node( $nodeName, $nodeValue );
		if( !$this->isNode( $newNode ) )
		{
			$this->nodes[] = $newNode;
			return $newNode;
		}
		else
			return $this->getNode( $nodeName );
	}
1092771
public function convert(NodeType $nodeType, $propertyName, $rawValue, Context $context)
    {
        $propertyType = $nodeType->getPropertyType($propertyName);

        switch ($propertyType) {
            case 'string':
                return $rawValue;

            case 'reference':
                return $this->convertReference($rawValue, $context);

            case 'references':
                return $this->convertReferences($rawValue, $context);

            case 'DateTime':
                return $this->convertDateTime($rawValue);

            case 'integer':
                return $this->convertInteger($rawValue);

            case 'boolean':
                return $this->convertBoolean($rawValue);

            case 'array':
                return $this->convertArray($rawValue);

            default:
                $innerType = $propertyType;
                if ($propertyType !== null) {
                    try {
                        $parsedType = TypeHandling::parseType($propertyType);
                        $innerType = $parsedType['elementType'] ?: $parsedType['type'];
                    } catch (InvalidTypeException $exception) {
                    }
                }

                if ((is_string($rawValue) || is_array($rawValue)) && $this->objectManager->isRegistered($innerType) && $rawValue !== '') {
                    $propertyMappingConfiguration = new MvcPropertyMappingConfiguration();
                    $propertyMappingConfiguration->allowOverrideTargetType();
                    $propertyMappingConfiguration->allowAllProperties();
                    $propertyMappingConfiguration->skipUnknownProperties();
                    $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_MODIFICATION_ALLOWED, true);
                    $propertyMappingConfiguration->setTypeConverterOption(PersistentObjectConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);

                    return $this->propertyMapper->convert($rawValue, $propertyType, $propertyMappingConfiguration);
                } else {
                    return $rawValue;
                }
        }
    }
693945
public function encode(Parser $parser, Node\Variable $var, $values)
    {
        $values    = (array)$values;
        $list      = isset($values[0]);
        $reserved  = $this->reserved;
        $maps      = static::$reserved_chars;
        $sep       = $this->sep;
        $assoc_sep = '=';

        // non-explode modifier always use ',' as a separator
        if ($var->options['modifier'] !== '*') {
            $assoc_sep = $sep = ',';
        }

        array_walk($values, function(&$v, $k) use ($assoc_sep, $reserved, $list, $maps) {

            $encoded = rawurlencode($v);

            // assoc? encode key too
            if (!$list) {
                $encoded = rawurlencode($k).$assoc_sep.$encoded;
            }

            // rawurlencode is compliant with 'unreserved' set
            if (!$reserved) {
                $v = $encoded;
            }

            // decode chars in reserved set
            else {

                $v = str_replace(
                    array_keys($maps),
                    $maps,
                    $encoded
                );
            }
        });

        return implode($sep, $values);
    }
1183005
protected function lexVariable(): VariableNode
    {
        $start = $this->lexer->getToken();

        $this->expect(TokenKindEnum::DOLLAR);

        return new VariableNode($this->lexName(), $this->createLocation($start));
    }
215323
private function getAlteredQueryNode($fieldName, array $values)
    {
        $newNode = new OrNode();
        $defaultLanguageFieldName = $fieldName.'.'.$this->intUtils->getDefaultLanguage();

        foreach ($values as $singleValue) {
            $newNode->addQuery($this->getEqNode($fieldName, $singleValue));
            // search default language field (as new structure only has 'en' set after creation and no save)
            $newNode->addQuery(
                $this->getEqNode(
                    $defaultLanguageFieldName,
                    $singleValue
                )
            );
        }

        // add default match
        $newNode->addQuery($this->getEqNode($this->node->getField(), $this->getNodeValue()));

        if (!$this->nodeFieldNameHasLanguage()) {
            // if no language, we add it to the query to default node for default language
            $newNode->addQuery(
                $this->getEqNode(
                    $defaultLanguageFieldName,
                    $this->getNodeValue()
                )
            );
        }

        return $newNode;
    }
490407
public function parse($graph, $data, $format = 'jsonld', $baseUri = null)
    {
        parent::checkParseParams($graph, $data, $format, $baseUri);

        foreach ($data as $quad) {
            $subject = (string)$quad->getSubject();

            if ('_:' === substr($subject, 0, 2)) {
                $subject = $this->remapBnode($subject);
            }

            $predicate = (string)$quad->getProperty();

            if ($quad->getObject() instanceof IRI) {
                $object = [
                    'type' => 'uri',
                    'value' => (string)$quad->getObject()
                ];

                if ('_:' === substr($object['value'], 0, 2)) {
                    $object = [
                        'type' => 'bnode',
                        'value' => $this->remapBnode($object['value'])
                    ];
                }
            } else {
                $object = [
                    'type' => 'literal',
                    'value' => $quad->getObject()->getValue()
                ];

                if ($quad->getObject() instanceof LanguageTaggedString) {
                    $object['lang'] = $quad->getObject()->getLanguage();
                } else {
                    $object['datatype'] = $quad->getObject()->getType();
                }
            }

            $this->addTriple($subject, $predicate, $object);
        }
    }
864677
protected function parseDate($field, ValueExpression $valueExpression)
    {
        // check if we already have a snake case field name
        if (strpos($field, '_') <= 0) {
            $field = snake_case($field);
        }

        /* @var Carbon $dateValue */
        $dateValue = $valueExpression->getValue();

        $this->query->where(
            $field,
            $valueExpression->getExpression(),
            $dateValue->toDateTimeString()
        );
    }
1112871
public function getNodeByValue($value): ?Node {
        if (!$this->containsValue($value)) {
            return null;
        }
        $tmp = $this->getHead();
        while ($tmp !== null) {
            $val = $tmp->getValue();
            if (Comparator::equals($val, $value)) {
                //if the value is found then return it
                return $tmp;
            }
            $tmp = $tmp->getNext();
        }
        return null;
    }
772602
public function expandNonExplode(Parser $parser, Node\Variable $var, array $val)
    {
        if (empty($val)) {
            return null;
        }

        return $this->encode($parser, $var, $val);
    }
295416
public function parseValue($value, array $variables = null): EntityID
    {
        $value = parent::parseValue($value);

        return $this->createEntityID($value);
    }
597890
public function setVariables($variables)
    {
        $this->variables = [];
        foreach ($variables as $var => $value) {
            if ($value instanceof RationalNode) {
                $this->variables[$var] = $value;
            } elseif ($this->isInteger($value)) {
                $this->variables[$var] = new RationalNode(intval($value), 1);
            } else {
                $this->variables[$var] = $this->parseRational($value);
            }
        }
    }
1344735
public function match(string $variable = null, array $labels = []): self
    {
        $query = new self;
        $query->clauses = $this->clauses->add(
            new Clause\MatchClause(
                Clause\Expression\Path::startWithNode($variable, $labels)
            )
        );

        return $query;
    }
105558
private function execute(string $query, $payload = null, ?array $variables = null)
    {
        return GraphQL::executeQuery($this->schema, $query, $payload, $this->context, $variables)->toArray();
    }