Skip to content

Instantly share code, notes, and snippets.

@taion809
Created February 19, 2015 03:30
Show Gist options
  • Save taion809/8c07fac007159ea8d7d3 to your computer and use it in GitHub Desktop.
Save taion809/8c07fac007159ea8d7d3 to your computer and use it in GitHub Desktop.
Type resolver
<?php
/**
* Created by PhpStorm.
* User: njohns
* Date: 1/4/15
* Time: 9:49 AM
*/
namespace Rql\Types;
class TypeResolver
{
/**
* @param $type
* @return \Rql\Datum
*/
public static function resolve($type = null)
{
if(is_null($type)) {
return new Null();
}
if(is_string($type)) {
return new String($type);
}
if(is_bool($type)) {
return new Boolean($type);
}
if(is_numeric($type)) {
return new Number($type);
}
if(is_array($type)) {
return new ArrayType($type);
}
if(is_object($type)) {
return new ObjectType($type);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment