Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
gds-php wrapper Type definition
<?php
namespace App\Datastore\Abstracts;
class Type {
const String = 1;
const Integer = 2;
const Datetime = 3;
const Float = 4;
const Boolean = 5;
const StringList = 6;
const Geopoint = 7;
const Json = 8;
public static function setProperty($obj_schema, $property, $type, $index = FALSE) {
switch ($type) {
case self::String:
$obj_schema->addString($property, $index);
break;
case self::Integer:
$obj_schema->addInteger($property, $index);
break;
case self::Datetime:
$obj_schema->addDatetime($property, $index);
break;
case self::Float:
$obj_schema->addFloat($property, $index);
break;
case self::Boolean:
$obj_schema->addBoolean($property, $index);
break;
case self::StringList:
$obj_schema->addStringList($property, $index);
break;
case self::Geopoint:
$obj_schema->addGeopoint($property, $index);
break;
case self::Json:
$obj_schema->addString($property, $index);
break;
default:
if ($index) throw new Exception("Invalid Datastore Entity Property Type", 1);
else self::setProperty($obj_schema, $property, $type[0], TRUE);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment