BigQuery/src/ValueMapper.php
public function toParameter($value)
    {
        $pValue = ['value' => $value];
        $type = gettype($value);

        switch ($type) {
            case 'boolean':
                $pType['type'] = self::TYPE_BOOL;

                break;
            case 'integer':
                $pType['type'] = self::TYPE_INT64;

                break;
            case 'double':
                $pType['type'] = self::TYPE_FLOAT64;

                break;
            case 'string':
                $pType['type'] = self::TYPE_STRING;

                break;
            case 'resource':
                $pType['type'] = self::TYPE_BYTES;
                $pValue['value'] = base64_encode(stream_get_contents($value));

                break;
            case 'object':
                list($pType, $pValue) = $this->objectToParameter($value);

                break;
            case 'array':
                list($pType, $pValue) = $this->isAssoc($value)
                    ? $this->assocArrayToParameter($value)
                    : $this->arrayToParameter($value);

                break;
            default:
                throw new \InvalidArgumentException(sprintf(
                    'Unrecognized value type %s. Please ensure you are using the latest version of google/cloud.',
                    $type
                ));

                break;
        }

        return [
            'parameterType' => $pType,
            'parameterValue' => $pValue
        ];
    }
public function toParameter($value)
    {
        $pValue = ['value' => $value];
        $type = gettype($value);

        switch ($type) {
            case 'boolean':
                $pType['type'] = self::TYPE_BOOL;

                break;
            case 'integer':
                $pType['type'] = self::TYPE_INT64;

                break;
            case 'double':
                $pType['type'] = self::TYPE_FLOAT64;

                break;
            case 'string':
                $pType['type'] = self::TYPE_STRING;

                break;
            case 'resource':
                $pType['type'] = self::TYPE_BYTES;
                $pValue['value'] = base64_encode(stream_get_contents($value));

                break;
            case 'object':
                list($pType, $pValue) = $this->objectToParameter($value);

                break;
            case 'array':
                list($pType, $pValue) = $this->isAssoc($value)
                    ? $this->assocArrayToParameter($value)
                    : $this->arrayToParameter($value);

                break;
            default:
                throw new \InvalidArgumentException(sprintf(
                    'Unrecognized value type %s. Please ensure you are using the latest version of google/cloud.',
                    $type
                ));

                break;
        }

        return [
            'parameterType' => $pType,
            'parameterValue' => $pValue
        ];
    }
public function toParameter ( $ value ) { $ pValue = [ 'value' => $ value ] ; $ type = gettype ( $ value ) ; switch ( $ type ) { case 'boolean' : $ pType [ 'type' ] = self :: TYPE_BOOL ; break ; case 'integer' : $ pType [ 'type' ] = self :: TYPE_INT64 ; break ; case 'double' : $ pType [ 'type' ] = self :: TYPE_FLOAT64 ; break ; case 'string' : $ pType [ 'type' ] = self :: TYPE_STRING ; break ; case 'resource' : $ pType [ 'type' ] = self :: TYPE_BYTES ; $ pValue [ 'value' ] = base64_encode ( stream_get_contents ( $ value ) ) ; break ; case 'object' : list ( $ pType , $ pValue ) = $ this -> objectToParameter ( $ value ) ; break ; case 'array' : list ( $ pType , $ pValue ) = $ this -> isAssoc ( $ value ) ? $ this -> assocArrayToParameter ( $ value ) : $ this -> arrayToParameter ( $ value ) ; break ; default : throw new \ InvalidArgumentException ( sprintf ( 'Unrecognized value type %s. Please ensure you are using the latest version of google/cloud.' , $ type ) ) ; break ; } return [ 'parameterType' => $ pType , 'parameterValue' => $ pValue ] ; }
Maps a value to the expected parameter format.

@param mixed $value The value to map.
@return array
@throws \InvalidArgumentException
Maps a value to the expected parameter format .