Skip to content

Commit

Permalink
PSR2 formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Uncle Cheese committed Jan 31, 2017
1 parent 9e13fbf commit 0183b6d
Show file tree
Hide file tree
Showing 12 changed files with 290 additions and 54,801 deletions.
54,508 changes: 0 additions & 54,508 deletions client/dist/graphiql.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function index(HTTPRequest $request)
}
$contentType = $request->getHeader('Content-Type') ?: $request->getHeader('content-type');
$isJson = preg_match('#^application/json\b#', $contentType);
if ($isJson) {
if ($isJson) {
$rawBody = $request->getBody();
$data = json_decode($rawBody ?: '', true);
$query = isset($data['query']) ? $data['query'] : null;
Expand Down
2 changes: 1 addition & 1 deletion src/FieldCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getAttributes()
$attributes['type'] = $type;
}

$resolver = $this->getResolver();
$resolver = $this->getResolver();
if (isset($resolver)) {
$attributes['resolve'] = $resolver;
}
Expand Down
34 changes: 17 additions & 17 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,31 @@ public static function createFromConfig($config)
/** @var Manager $manager */
$manager = Injector::inst()->create(Manager::class);

if(isset($config['scaffolding'])) {
$scaffolder = SchemaScaffolder::createFromConfig($config['scaffolding']);
if (isset($config['scaffolding'])) {
$scaffolder = SchemaScaffolder::createFromConfig($config['scaffolding']);
} else {
$scaffolder = new SchemaScaffolder();
$scaffolder = new SchemaScaffolder();
}

if(isset($config['scaffolding_providers'])) {
foreach($config['scaffolding_providers'] as $provider) {
if(!class_exists($provider)) {
if (isset($config['scaffolding_providers'])) {
foreach ($config['scaffolding_providers'] as $provider) {
if (!class_exists($provider)) {
throw new InvalidArgumentException(sprintf(
'Scaffolding provider %s does not exist.',
$provider
));
}
$provider = Injector::inst()->create($provider);
));
}
$provider = Injector::inst()->create($provider);

if(!$provider instanceof ScaffoldingProvider) {
if (!$provider instanceof ScaffoldingProvider) {
throw new InvalidArgumentException(sprintf(
'All scaffolding providers must implement the %s interface',
ScaffoldingProvider::class
));
}
$scaffolder = $provider->provideGraphQLScaffolding($scaffolder);
}
));
}
$scaffolder = $provider->provideGraphQLScaffolding($scaffolder);
}
}

$scaffolder->addToManager($manager);
Expand Down Expand Up @@ -219,12 +219,12 @@ public function getType($name)

/**
* @param string $name
*
*
* @return boolean
*/
public function hasType($name)
{
return isset($this->types[$name]);
return isset($this->types[$name]);
}

/**
Expand Down
261 changes: 130 additions & 131 deletions src/Scaffolding/Scaffolders/ArgumentScaffolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,134 +11,133 @@
class ArgumentScaffolder implements Configurable
{

/**
* @var string
*/
public $argName;

/**
* @var string
*/
protected $description;

/**
* @var GraphQL\Definition\Type\Type;
*/
protected $type;

/**
* @var scalar
*/
protected $defaultValue;

/**
* @var boolean
*/
protected $required;

/**
* ArgumentScaffolder constructor
* @param string $argName Name of the argument
* @param strint $typeStr A string describing the type (see TypeParser)
*/
public function __construct($argName, $typeStr)
{
$this->argName = $argName;

$parser = new TypeParser($typeStr);
$this->defaultValue = $parser->getDefaultValue();
$this->type = $parser->getType();
$this->required = $parser->isRequired();
}

/**
* Sets the argument as required
* @param boolean $bool
*/
public function setRequired($bool)
{
$this->required = (boolean) $bool;

return $this;
}

/**
* Sets the argument description
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;

return $this;
}

/**
* Sets the default value of the argument
* @param mixed $value
*/
public function setDefaultValue($value)
{
$this->defaultValue = $value;

return $this;
}

/**
* @return string
*/
public function getDescription()
{
return $this->description;
}

/**
* @return scalar
*/
public function getDefaultValue()
{
return $this->defaultValue;
}

/**
* @return boolean
*/
public function isRequired()
{
return $this->required;
}

/**
* Applies an array of configuration to the scaffolder
* @param array $config
* @return void
*/
public function applyConfig(array $config)
{
if(isset($config['description'])) {
$this->description = $config['description'];
}

if(isset($config['default'])) {
$this->defaultValue = $config['default'];
}

if(isset($config['required'])) {
$this->required = (boolean) $config['required'];
}
}

/**
* Creates an array suitable for a map of args in a field
* @return array
*/
public function toArray()
{
return [
'description' => $this->description,
'type' => $this->required ? Type::nonNull($this->type) : $this->type,
'defaultValue' => $this->defaultValue
];
}

}
/**
* @var string
*/
public $argName;

/**
* @var string
*/
protected $description;

/**
* @var GraphQL\Definition\Type\Type;
*/
protected $type;

/**
* @var scalar
*/
protected $defaultValue;

/**
* @var boolean
*/
protected $required;

/**
* ArgumentScaffolder constructor
* @param string $argName Name of the argument
* @param strint $typeStr A string describing the type (see TypeParser)
*/
public function __construct($argName, $typeStr)
{
$this->argName = $argName;

$parser = new TypeParser($typeStr);
$this->defaultValue = $parser->getDefaultValue();
$this->type = $parser->getType();
$this->required = $parser->isRequired();
}

/**
* Sets the argument as required
* @param boolean $bool
*/
public function setRequired($bool)
{
$this->required = (boolean) $bool;

return $this;
}

/**
* Sets the argument description
* @param string $description
*/
public function setDescription($description)
{
$this->description = $description;

return $this;
}

/**
* Sets the default value of the argument
* @param mixed $value
*/
public function setDefaultValue($value)
{
$this->defaultValue = $value;

return $this;
}

/**
* @return string
*/
public function getDescription()
{
return $this->description;
}

/**
* @return scalar
*/
public function getDefaultValue()
{
return $this->defaultValue;
}

/**
* @return boolean
*/
public function isRequired()
{
return $this->required;
}

/**
* Applies an array of configuration to the scaffolder
* @param array $config
* @return void
*/
public function applyConfig(array $config)
{
if (isset($config['description'])) {
$this->description = $config['description'];
}

if (isset($config['default'])) {
$this->defaultValue = $config['default'];
}

if (isset($config['required'])) {
$this->required = (boolean) $config['required'];
}
}

/**
* Creates an array suitable for a map of args in a field
* @return array
*/
public function toArray()
{
return [
'description' => $this->description,
'type' => $this->required ? Type::nonNull($this->type) : $this->type,
'defaultValue' => $this->defaultValue
];
}
}
2 changes: 1 addition & 1 deletion src/Scaffolding/Scaffolders/CRUD/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function generateInputType()
$result = $instance->obj($dbFieldName);
$typeName = $result->config()->graphql_type;
$arr = [
'type' => (new TypeParser($typeName))->getType()
'type' => (new TypeParser($typeName))->getType()
];
$fields[$dbFieldName] = $arr;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Scaffolding/Scaffolders/CRUD/Read.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public function __construct($dataObjectClass)
parent::__construct($operationName, $this->typeName());

$this->setResolver(function ($object, array $args, $context, $info) {
if(!singleton($this->dataObjectClass)->canView($context['currentMember'])) {
throw new Exception(sprintf(
'Cannot create %s',
$this->dataObjectClass
));
if (!singleton($this->dataObjectClass)->canView($context['currentMember'])) {
throw new Exception(sprintf(
'Cannot create %s',
$this->dataObjectClass
));
}

$list = DataList::create($this->dataObjectClass);
Expand Down
4 changes: 2 additions & 2 deletions src/Scaffolding/Scaffolders/CRUD/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function createArgs()
{
return [
'ID' => [
'type' => Type::nonNull(Type::id())
'type' => Type::nonNull(Type::id())
],
'Input' => [
'type' => Type::nonNull($this->generateInputType()),
Expand Down Expand Up @@ -109,7 +109,7 @@ protected function generateInputType()
$result = $instance->obj($dbFieldName);
$typeName = $result->config()->graphql_type;
$arr = [
'type' => (new TypeParser($typeName))->getType()
'type' => (new TypeParser($typeName))->getType()
];
$fields[$dbFieldName] = $arr;
}
Expand Down
Loading

0 comments on commit 0183b6d

Please sign in to comment.