Created
May 15, 2016 08:40
-
-
Save netcell/1fc8baa53b91cd64b8e281d324afa5cf to your computer and use it in GitHub Desktop.
gds-php wrapper Type definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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