You are here

Uppercase.php in GraphQL 8.4

File

src/Plugin/GraphQL/DataProducer/String/Uppercase.php
View source
<?php

namespace Drupal\graphql\Plugin\GraphQL\DataProducer\String;

use Drupal\graphql\Plugin\GraphQL\DataProducer\DataProducerPluginBase;

/**
 * Transforms a string to uppercase.
 *
 * @DataProducer(
 *   id = "uppercase",
 *   name = @Translation("Uppercase"),
 *   description = @Translation("Transforms a string to uppercase."),
 *   produces = @ContextDefinition("string",
 *     label = @Translation("Uppercased string")
 *   ),
 *   consumes = {
 *     "string" = @ContextDefinition("string",
 *       label = @Translation("String")
 *     )
 *   }
 * )
 */
class Uppercase extends DataProducerPluginBase {

  /**
   * Value resolver.
   *
   * @param string $string
   *
   * @return string
   */
  public function resolve($string) {
    return strtoupper($string);
  }

}

Classes

Namesort descending Description
Uppercase Transforms a string to uppercase.