Inheritance: use trait Google\Cloud\ArrayTrait, use trait DatastoreTrait
Ejemplo n.º 1
0
 /**
  * Format bound values for the API
  *
  * @param string $bindingType Either named or positional bindings.
  * @param array $bindings The bindings to map
  * @return array
  */
 private function mapBindings($bindingType, array $bindings)
 {
     $res = [];
     foreach ($bindings as $key => $binding) {
         $value = $this->entityMapper->valueObject($binding);
         if ($bindingType === self::BINDING_NAMED) {
             $res[$key] = ['value' => $value];
         } else {
             $res[] = ['value' => $value];
         }
     }
     return $res;
 }
Ejemplo n.º 2
0
 /**
  * Add a filter to the query.
  *
  * If the top-level filter is specified as a propertyFilter, it will be replaced.
  * Any composite filters will be preserved and the new filter will be added.
  *
  * Example:
  * ```
  * $query->filter('firstName', '=', 'Bob')
  *     ->filter('lastName', '=', 'Testguy');
  * ```
  *
  * @see https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#operator_1 Allowed Operators
  *
  * @param string $property The property to filter.
  * @param string $operator The operator to use in the filter. A list of
  *        allowed operators may be found
  *        [here](https://cloud.google.com/datastore/reference/rest/v1/projects/runQuery#operator_1).
  *        Short comparison operators are provided for convenience and are
  *        mapped to their datastore-compatible equivalents. Available short
  *        operators are `=`, `<`, `<=`, `>`, and `>=`.
  * @param mixed $value The value to check.
  * @return Query
  */
 public function filter($property, $operator, $value)
 {
     if (!isset($this->query['filter']) || !isset($this->query['filter']['compositeFilter'])) {
         $this->initializeFilter();
     }
     $this->query['filter']['compositeFilter']['filters'][] = ['propertyFilter' => ['property' => $this->propertyName($property), 'value' => $this->entityMapper->valueObject($value), 'op' => $this->mapOperator($operator)]];
     return $this;
 }
Ejemplo n.º 3
0
 public function testObjectPropertyBlobNotEncoded()
 {
     $mapper = new EntityMapper('foo', false);
     $res = $mapper->valueObject(new Blob('hello world'));
     $this->assertEquals('hello world', $res['blobValue']);
 }
 public function testReturnsInt64AsObject()
 {
     $int = '914241242';
     $mapper = new EntityMapper('foo', true, true);
     $res = $mapper->convertValue('integerValue', $int);
     $this->assertInstanceOf(Int64::class, $res);
     $this->assertEquals($int, $res->get());
 }