Returns the class name to be used for the given SchemaDescriptor.

@param SchemaDescriptor $schema
@param bool             $withMajor

@return string
504175
public function schemaToClassName(SchemaDescriptor $schema, $withMajor = false)
    {
        $className = StringUtils::toCamelFromSlug($schema->getId()->getMessage());
        if (!$withMajor) {
            return $className;
        }

        return "{$className}V{$schema->getId()->getVersion()->getMajor()}";
    }
745862
private function getClassInfo(string $className, int $specVersion = 2): stdClass
    {
        $nodes = 2 === $specVersion ? $this->getLastJsonResponse()->{'definitions'} : $this->getLastJsonResponse()->{'components'}->{'schemas'};
        foreach ($nodes as $classTitle => $classData) {
            if ($classTitle === $className) {
                return $classData;
            }
        }

        throw new \InvalidArgumentException(sprintf('Class %s cannot be found in the vocabulary', $className));
    }
362145
public function getDocComment ( $withCommentMark = false ) {
        $docComment = $this->_reflectionMethod->getDocComment();
        if ( $withCommentMark === true ) {
            $docComment = PhpDocCommentObject::ltrim($docComment);
        } else {
            $docComment = PhpDocCommentObject::stripCommentMarks($docComment);
        }
        return $docComment;
    }
365034
protected function getOperationType(Schema $schema, OperationDefinitionNode $operation): ?ObjectType
    {
        switch ($operation->getOperation()) {
            case 'query':
                return $schema->getQueryType();
            case 'mutation':
                $mutationType = $schema->getMutationType();

                if (null === $mutationType) {
                    throw new ExecutionException('Schema is not configured for mutations.', [$operation]);
                }

                return $mutationType;
            case 'subscription':
                $subscriptionType = $schema->getSubscriptionType();

                if (null === $subscriptionType) {
                    throw new ExecutionException('Schema is not configured for subscriptions.', [$operation]);
                }

                return $subscriptionType;
            default:
                throw new ExecutionException('Can only execute queries, mutations and subscriptions.', [$operation]);
        }
    }
1186409
private static function getSchemaClassName($schemaName)
    {
        // Upgrade from pre 2.0.4
        if (strtolower($schemaName) == 'myisam'
            || empty($schemaName)) {
            $schemaName = self::DEFAULT_SCHEMA;
        }

        $class = str_replace(' ', '\\', ucwords(str_replace('_', ' ', strtolower($schemaName))));
        return '\Piwik\Db\Schema\\' . $class;
    }
529553
protected function getFieldTypeName(FieldDescriptorProto $field)
    {
        $type = $field->getType()->value();
        $name = Field::getTypeName($type);

        return $name ?: 'unknown';
    }
1368511
protected function _getCallableObject($sClassName, array $aOptions)
    {
        // Make sure the registered class exists
        if(key_exists('include', $aOptions))
        {
            require_once($aOptions['include']);
        }
        if(!class_exists($sClassName))
        {
            return null;
        }

        // Create the callable object
        $xCallableObject = new \Jaxon\Request\Support\CallableObject($sClassName);
        $this->aCallableOptions[$sClassName] = [];
        foreach($aOptions as $sName => $xValue)
        {
            if($sName == 'separator' || $sName == 'protected')
            {
                $xCallableObject->configure($sName, $xValue);
            }
            elseif(is_array($xValue) && $sName != 'include')
            {
                // These options are to be included in javascript code.
                $this->aCallableOptions[$sClassName][$sName] = $xValue;
            }
        }
        $this->aCallableObjects[$sClassName] = $xCallableObject;

        // Register the request factory for this callable object
        jaxon()->di()->set($sClassName . '_Factory_Rq', function () use ($sClassName) {
            $xCallableObject = $this->aCallableObjects[$sClassName];
            return new \Jaxon\Factory\Request\Portable($xCallableObject);
        });
        // Register the paginator factory for this callable object
        jaxon()->di()->set($sClassName . '_Factory_Pg', function () use ($sClassName) {
            $xCallableObject = $this->aCallableObjects[$sClassName];
            return new \Jaxon\Factory\Request\Paginator($xCallableObject);
        });

        return $xCallableObject;
    }
151569
public function describeStorage($name, $schema = false)
    {
        if (!$schema) {
            $schema = $this->connector->getSchema();
        }

        return $this->describeTable($name, $schema);
    }
508103
protected function callSchema($schema)
    {
        if (!$schema instanceof Schema && is_callable($schema)) {
            $s = $this->getSchema();

            $schema($s);

            $schema = $s;
        }

        if (!$schema instanceof Schema) {
            throw new \InvalidArgumentException('Argument 1 should be Schema object.');
        }

        return $schema;
    }
1365299
protected function getSchemaFileName($folder, $schema)
    {
        $file = null;

        foreach (['yml', 'yaml'] as $ext) {
            $fileCheck = $folder.'/'.$schema.'.'.$ext;
            if (is_readable($fileCheck)) {
                $file = $fileCheck;
                break;
            }
        }

        if (is_null($file)) {
            throw new SchemaParserException(sprintf('Cannot find schema for "%s" in "%s"', $schema, $folder));
        }

        return $file;
    }
333711
private function describeTable($name, $schema)
    {
        $data = $this->connector->getQueryAsSingleRow(
                'SELECT t.table_schema AS table_schema, t.table_name AS table_name, t.engine AS engine,
                        t.auto_increment AS auto_increment, t.table_collation AS table_collation,
                        t.table_comment AS table_comment, cs.character_set_name AS table_charset,
                        t.create_options AS create_options
                   FROM information_schema.tables t, information_schema.character_sets cs
                  WHERE t.table_schema=\'%schema$s\'
                    AND t.table_name = \'%table$s\'
                    AND t.table_collation = cs.default_collate_name',
                array(
                    'schema' => $schema,
                    'table' => $name
                )
        );

        if (is_array($data)) {
            $fields = $this->describeTableFields($name, $schema);
            $table['schema'] = $data['table_schema'];
            $table['name'] = $data['table_name'];
            $table['engine'] = $data['engine'];
            $table['type'] = CMySQLConnector::TYPE_TABLE;
            $table['autoincrement'] = $this->validateAutoIncrement($data['auto_increment'], $fields);
            $table['charset'] = $data['table_charset'];
            $table['collation'] = $data['table_collation'];
            $table['create_options'] = $data['create_options'];
            $table['comment'] = $data['table_comment'];
            $table['fields'] = $fields;
            $table['constraints'] = $this->describeTableConstraints($name, $table['fields'], $schema);
            $descriptor = new CMySQLDescriptor($this->connector, $table);
        } else {
            $descriptor = null;
        }

        return $descriptor;
    }
1097814
public function getName($withGroup = false)
    {
        $group = $withGroup ? $this->getGroup() : '';

        $group = $group ? $group . '/' : '';

        return $group . $this->name;
    }
1166113
private function findTableSchemas($schema = null)
    {
        $tableNames = $this->getTableNames($schema, true);

        if (is_callable($this->tableNameFilter)) {
            $tableNames = array_filter($tableNames,
                function($tableName) use ($schema) {
                    return call_user_func($this->tableNameFilter, $tableName, $schema);
                }
            );
        }

        $tableSchemas = array_map(
            function($tableName) use ($schema) {
                $tableSchema = new TableSchema();
                $tableNameFull = $schema === null ? $tableName : "$schema.$tableName";
                $this->resolveTableNames($tableSchema, $tableNameFull);
                return $tableSchema;
            },
            $tableNames);

        return $tableSchemas;
    }
898653
private static function getDescriptionConfiguration(array $annotations, bool $withDeprecation = false)
    {
        $config = [];
        $descriptionAnnotation = self::getFirstAnnotationMatching($annotations, 'Overblog\GraphQLBundle\Annotation\Description');
        if ($descriptionAnnotation) {
            $config['description'] = $descriptionAnnotation->value;
        }

        if ($withDeprecation) {
            $deprecatedAnnotation = self::getFirstAnnotationMatching($annotations, 'Overblog\GraphQLBundle\Annotation\Deprecated');
            if ($deprecatedAnnotation) {
                $config['deprecationReason'] = $deprecatedAnnotation->value;
            }
        }

        return $config;
    }
1306929
protected function validateObjectSchema($schema)
    {
        if (empty($schema->getAttributeMap())) {
            throw new SchemaParserException(sprintf('Object type "%s" has no attributes defined.', $schema->getObjectType()));
        } elseif (!((bool)count(array_filter(array_keys($schema->getAttributeMap()), 'is_string')))) {
            throw new SchemaParserException('The attributes for a schema should be an associative array.');
        }
        
        if ($schema->getScope() && !in_array($schema->getScope(), QueryOperation::SCOPE)) {
            throw new SchemaParserException(sprintf(
                'The scope "%s" is not valid. Valid types are: %s',
                $schema->getScope(),
                implode(', ', QueryOperation::SCOPE)
            ));
        }
    }
1052430
public static function getServerNameOrIp($withProtocol = false)
    {
        $host = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'HTTP_HOST');

        /*
         * Unknown host / server?
         * Nothing to do
         */
        if (empty($host)) {
            return '';
        }

        /*
         * With protocol?
         * Let's include the protocol
         */
        if ($withProtocol) {
            return sprintf('%s://%s', self::getProtocolName(), $host);
        }

        return $host;
    }
324783
public function isSameNamespace(SchemaDescriptor $a, SchemaDescriptor $b)
    {
        $ans = $this->generator->schemaToNativeNamespace($a);
        $bns = $this->generator->schemaToNativeNamespace($b);
        return $ans == $bns;
    }