Serialized \Google\Protobuf\SourceCodeInfo\Location to Protocol Buffers message.

@param Location $object
@param array $filter

@throws \Exception

@return string
16399
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->path) && ($filter === null || isset($filter['path']))) {
			$packedBuffer = '';
			$output .= "\x0a";
			foreach ($object->path instanceof \Traversable ? $object->path : (array)$object->path as $k => $v) {
				$packedBuffer .= Binary::encodeVarint($v);
			}
			$output .= Binary::encodeVarint(strlen($packedBuffer));
			$output .= $packedBuffer;
		}

		if (isset($object->span) && ($filter === null || isset($filter['span']))) {
			$packedBuffer = '';
			$output .= "\x12";
			foreach ($object->span instanceof \Traversable ? $object->span : (array)$object->span as $k => $v) {
				$packedBuffer .= Binary::encodeVarint($v);
			}
			$output .= Binary::encodeVarint(strlen($packedBuffer));
			$output .= $packedBuffer;
		}

		if (isset($object->leadingComments) && ($filter === null || isset($filter['leadingComments']))) {
			$output .= "\x1a";
			$output .= Binary::encodeVarint(strlen($object->leadingComments));
			$output .= $object->leadingComments;
		}

		if (isset($object->trailingComments) && ($filter === null || isset($filter['trailingComments']))) {
			$output .= "\x22";
			$output .= Binary::encodeVarint(strlen($object->trailingComments));
			$output .= $object->trailingComments;
		}

		if (isset($object->leadingDetachedComments) && ($filter === null || isset($filter['leadingDetachedComments']))) {
			foreach ($object->leadingDetachedComments instanceof \Traversable ? $object->leadingDetachedComments : (array)$object->leadingDetachedComments as $k => $v) {
				$output .= "\x32";
				$output .= Binary::encodeVarint(strlen($v));
				$output .= $v;
			}
		}

		return $output;
	}
1051985
public function getSearchRequest($filter, $limit = 1, $conditions = [])
    {
        $self = $this;
        $knownFilters = $this->_getSearchFilters();
        $request = new StorageDataRequest(
            [$filter, $limit, $conditions],
            function ($filter, $limit, $conditions) use ($self, $knownFilters) {
                $items = $self->getAllItems();
                $results = [];
                $filterRules = [];
                
                foreach ($filter as $filterRequest) {
                    if (\count($filterRequest) === 3) {
                        list ($key, $compare, $compareValue) = $filterRequest;
                        
                        if (isset($knownFilters[$compare])) {
                            $filterRules[] = [$key, $knownFilters[$compare], $compareValue];
                        } else {
                            trigger_error('Comparator not found for filter: '.json_encode($filterRequest).'');
                        }
                    } else {
                        trigger_error('Strange filter: less than 3 parameters, '.json_encode($filterRequest));
                    }
                }
                
                foreach ($items as $id) {
                    $pointer = $self->getPointer($id);
                    $isOk = true;
                    if ($pointer) {
                        $record = json_decode(stream_get_contents($pointer), true);
                        
                        if (isset($record[self::F_DATA])) {
                            foreach ($filterRules as $filterRule) {
                                list ($key, $function, $filterRequest) = $filterRule;
        
                                $isOk = $isOk && call_user_func($function, $record[self::F_DATA][$key] ?? null, $filterRequest);
        
                                if (!$isOk) {
                                    break;
                                }
                            }
    
                            if ($isOk) {
                                $results[$id] = [$this->primaryKey => $id] + $record[self::F_DATA];
                            }    
                        }
                        
                        $self->closePointer($pointer);
                        
                        if (count($results) >= $limit) {
                            break;
                        }
                    }
                }
                
                if ($results && $conditions) {
                    $self->applyConditions($results, $conditions);
                }
            
                return $results;
            }
        );
    
        return $request;
    }
807343
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->name) && ($filter === null || isset($filter['name']))) {
			$output .= "\x0a";
			$output .= Binary::encodeVarint(strlen($object->name));
			$output .= $object->name;
		}

		if (isset($object->number) && ($filter === null || isset($filter['number']))) {
			$output .= "\x10";
			$output .= Binary::encodeVarint($object->number);
		}

		if (isset($object->options) && ($filter === null || isset($filter['options']))) {
			$output .= "\x1a";
			$buffer = EnumValueOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
			$output .= Binary::encodeVarint(strlen($buffer));
			$output .= $buffer;
		}

		return $output;
	}
766452
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->name) && ($filter === null || isset($filter['name']))) {
			$output .= "\x0a";
			$output .= Binary::encodeVarint(strlen($object->name));
			$output .= $object->name;
		}

		if (isset($object->package) && ($filter === null || isset($filter['package']))) {
			$output .= "\x12";
			$output .= Binary::encodeVarint(strlen($object->package));
			$output .= $object->package;
		}

		if (isset($object->dependency) && ($filter === null || isset($filter['dependency']))) {
			foreach ($object->dependency instanceof \Traversable ? $object->dependency : (array)$object->dependency as $k => $v) {
				$output .= "\x1a";
				$output .= Binary::encodeVarint(strlen($v));
				$output .= $v;
			}
		}

		if (isset($object->publicDependency) && ($filter === null || isset($filter['publicDependency']))) {
			foreach ($object->publicDependency instanceof \Traversable ? $object->publicDependency : (array)$object->publicDependency as $k => $v) {
				$output .= "\x50";
				$output .= Binary::encodeVarint($v);
			}
		}

		if (isset($object->weakDependency) && ($filter === null || isset($filter['weakDependency']))) {
			foreach ($object->weakDependency instanceof \Traversable ? $object->weakDependency : (array)$object->weakDependency as $k => $v) {
				$output .= "\x58";
				$output .= Binary::encodeVarint($v);
			}
		}

		if (isset($object->messageType) && ($filter === null || isset($filter['messageType']))) {
			foreach ($object->messageType instanceof \Traversable ? $object->messageType : (array)$object->messageType as $k => $v) {
				$output .= "\x22";
				$buffer = DescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['messageType']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		if (isset($object->enumType) && ($filter === null || isset($filter['enumType']))) {
			foreach ($object->enumType instanceof \Traversable ? $object->enumType : (array)$object->enumType as $k => $v) {
				$output .= "\x2a";
				$buffer = EnumDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['enumType']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		if (isset($object->service) && ($filter === null || isset($filter['service']))) {
			foreach ($object->service instanceof \Traversable ? $object->service : (array)$object->service as $k => $v) {
				$output .= "\x32";
				$buffer = ServiceDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['service']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		if (isset($object->extension) && ($filter === null || isset($filter['extension']))) {
			foreach ($object->extension instanceof \Traversable ? $object->extension : (array)$object->extension as $k => $v) {
				$output .= "\x3a";
				$buffer = FieldDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['extension']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		if (isset($object->options) && ($filter === null || isset($filter['options']))) {
			$output .= "\x42";
			$buffer = FileOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
			$output .= Binary::encodeVarint(strlen($buffer));
			$output .= $buffer;
		}

		if (isset($object->sourceCodeInfo) && ($filter === null || isset($filter['sourceCodeInfo']))) {
			$output .= "\x4a";
			$buffer = SourceCodeInfoMeta::toProtobuf($object->sourceCodeInfo, $filter === null ? null : $filter['sourceCodeInfo']);
			$output .= Binary::encodeVarint(strlen($buffer));
			$output .= $buffer;
		}

		if (isset($object->syntax) && ($filter === null || isset($filter['syntax']))) {
			$output .= "\x62";
			$output .= Binary::encodeVarint(strlen($object->syntax));
			$output .= $object->syntax;
		}

		return $output;
	}
103057
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL)
	{
		if ($object === null) {
			$object = new ServiceDescriptorProto();
		}

		if ($end === null) {
			$end = strlen($input);
		}

		while ($start < $end) {
			$tag = Binary::decodeVarint($input, $start);
			$wireType = $tag & 0x7;
			$number = $tag >> 3;
			switch ($number) {
				case 1:
					if ($wireType !== 2) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
					}
					$length = Binary::decodeVarint($input, $start);
					$expectedStart = $start + $length;
					if ($expectedStart > $end) {
						throw new ProtobufException('Not enough data.');
					}
					$object->name = substr($input, $start, $length);
					$start += $length;
					if ($start !== $expectedStart) {
						throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
					}
					break;
				case 2:
					if ($wireType !== 2) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
					}
					if (!(isset($object->method) && is_array($object->method))) {
						$object->method = array();
					}
					$length = Binary::decodeVarint($input, $start);
					$expectedStart = $start + $length;
					if ($expectedStart > $end) {
						throw new ProtobufException('Not enough data.');
					}
					$object->method[] = MethodDescriptorProtoMeta::fromProtobuf($input, null, $start, $start + $length);
					if ($start !== $expectedStart) {
						throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
					}
					break;
				case 3:
					if ($wireType !== 2) {
						throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number);
					}
					$length = Binary::decodeVarint($input, $start);
					$expectedStart = $start + $length;
					if ($expectedStart > $end) {
						throw new ProtobufException('Not enough data.');
					}
					$object->options = ServiceOptionsMeta::fromProtobuf($input, null, $start, $start + $length);
					if ($start !== $expectedStart) {
						throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number);
					}
					break;
				default:
					switch ($wireType) {
						case 0:
							Binary::decodeVarint($input, $start);
							break;
						case 1:
							$start += 8;
							break;
						case 2:
							$start += Binary::decodeVarint($input, $start);
							break;
						case 5:
							$start += 4;
							break;
						default:
							throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number);
					}
			}
		}

		return $object;
	}
720871
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->error) && ($filter === null || isset($filter['error']))) {
			$output .= "\x0a";
			$output .= Binary::encodeVarint(strlen($object->error));
			$output .= $object->error;
		}

		if (isset($object->file) && ($filter === null || isset($filter['file']))) {
			foreach ($object->file instanceof \Traversable ? $object->file : (array)$object->file as $k => $v) {
				$output .= "\x7a";
				$buffer = FileMeta::toProtobuf($v, $filter === null ? null : $filter['file']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		return $output;
	}
53909
public function findOne(array $filter = [], array $options = [])
    {
        $options['typeMap'] = ['root' => 'array', 'document' => 'array', 'array' => 'array'];

        if ($originalValues = $this->collection->findOne($filter, $options)) {
            $values = $this->convertValues->convertToPHPValues($originalValues);


            $object = $this->hydrator->hydrate($values);

            $this->changesCollector->register($object, $originalValues);

            return $object;
        }
    }
852055
public function getSearchRequest($filter, $limit = 1, $conditions = [])
    {
        $self = $this;

        return new StorageDataRequest(
            [$limit, $conditions],
            function ($limit, $conditions) use ($self) {
                $timeout = $conditions['timeout'] ?? 1;
                $consumer = $self->getRouter()->getConsumer($self->getResource(), $timeout);
                $results = [];

                while ($limit--) {
                    $results[] = $consumer->readOne();
                }

                return $results;
            }
        );
    }
1319917
public function getJsonProperty(string $name, $filter = 'string')
    {
        // manually filter since we are not going through getPost/Put
        $filterService = new Filter();

        $json = $this->getJsonRawBody();
        if (is_object($json)) {
            if (isset($json->$name)) {
                return $filterService->sanitize($json->$name, $filter);
            } else {
                // found valid json, but no matching property found
                return null;
            }
        } else {
            // expected name not found
            throw new HTTPException('Could not find expected json data.', 500, [
                'dev' => json_encode($json),
                'code' => '894984616161681468764'
            ]);
        }
    }
462395
public function getPosition($object, $movePosition, $lastPosition)
    {
        $currentPosition = $this->getCurrentPosition($object);
        $newPosition = 0;

        switch ($movePosition) {
            case 'up' :
                if ($currentPosition > 0) {
                    $newPosition = $currentPosition - 1;
                }
                break;

            case 'down':
                if ($currentPosition < $lastPosition) {
                    $newPosition = $currentPosition + 1;
                }
                break;

            case 'top':
                if ($currentPosition > 0) {
                    $newPosition = 0;
                }
                break;

            case 'bottom':
                if ($currentPosition < $lastPosition) {
                    $newPosition = $lastPosition;
                }
                break;

            default:
                if (is_numeric($movePosition)) {
                    $newPosition = (int) $movePosition;
                }

        }

        return $newPosition;
    }
1111340
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->x) && ($filter === null || isset($filter['x']))) {
			$output .= "\x08";
			$output .= Binary::encodeVarint($object->x);
		}

		return $output;
	}
828141
public static function apply($context, $method, $filter)
    {
        static::$_cachedFilters = [];

        if (is_object($context)) {
            $instance = $context;
            $class = get_class($context);
        } else {
            $class = $context;
            $instance = null;
        }

        $filter = $filter->bindTo($instance, $class);

        $ref = static::_ref($context, $method);
        if (!isset(static::$_filters[$ref])) {
            static::$_filters[$ref] = [$filter];
        } else {
            array_unshift(static::$_filters[$ref], $filter);
        }
        return $ref . '|' . (count(static::$_filters[$ref]) - 1);
    }
1142411
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->javaPackage) && ($filter === null || isset($filter['javaPackage']))) {
			$output .= "\x0a";
			$output .= Binary::encodeVarint(strlen($object->javaPackage));
			$output .= $object->javaPackage;
		}

		if (isset($object->javaOuterClassname) && ($filter === null || isset($filter['javaOuterClassname']))) {
			$output .= "\x42";
			$output .= Binary::encodeVarint(strlen($object->javaOuterClassname));
			$output .= $object->javaOuterClassname;
		}

		if (isset($object->javaMultipleFiles) && ($filter === null || isset($filter['javaMultipleFiles']))) {
			$output .= "\x50";
			$output .= Binary::encodeVarint((int)$object->javaMultipleFiles);
		}

		if (isset($object->javaGenerateEqualsAndHash) && ($filter === null || isset($filter['javaGenerateEqualsAndHash']))) {
			$output .= "\xa0\x01";
			$output .= Binary::encodeVarint((int)$object->javaGenerateEqualsAndHash);
		}

		if (isset($object->javaStringCheckUtf8) && ($filter === null || isset($filter['javaStringCheckUtf8']))) {
			$output .= "\xd8\x01";
			$output .= Binary::encodeVarint((int)$object->javaStringCheckUtf8);
		}

		if (isset($object->optimizeFor) && ($filter === null || isset($filter['optimizeFor']))) {
			$output .= "\x48";
			$output .= Binary::encodeVarint($object->optimizeFor);
		}

		if (isset($object->goPackage) && ($filter === null || isset($filter['goPackage']))) {
			$output .= "\x5a";
			$output .= Binary::encodeVarint(strlen($object->goPackage));
			$output .= $object->goPackage;
		}

		if (isset($object->ccGenericServices) && ($filter === null || isset($filter['ccGenericServices']))) {
			$output .= "\x80\x01";
			$output .= Binary::encodeVarint((int)$object->ccGenericServices);
		}

		if (isset($object->javaGenericServices) && ($filter === null || isset($filter['javaGenericServices']))) {
			$output .= "\x88\x01";
			$output .= Binary::encodeVarint((int)$object->javaGenericServices);
		}

		if (isset($object->pyGenericServices) && ($filter === null || isset($filter['pyGenericServices']))) {
			$output .= "\x90\x01";
			$output .= Binary::encodeVarint((int)$object->pyGenericServices);
		}

		if (isset($object->deprecated) && ($filter === null || isset($filter['deprecated']))) {
			$output .= "\xb8\x01";
			$output .= Binary::encodeVarint((int)$object->deprecated);
		}

		if (isset($object->ccEnableArenas) && ($filter === null || isset($filter['ccEnableArenas']))) {
			$output .= "\xf8\x01";
			$output .= Binary::encodeVarint((int)$object->ccEnableArenas);
		}

		if (isset($object->objcClassPrefix) && ($filter === null || isset($filter['objcClassPrefix']))) {
			$output .= "\xa2\x02";
			$output .= Binary::encodeVarint(strlen($object->objcClassPrefix));
			$output .= $object->objcClassPrefix;
		}

		if (isset($object->csharpNamespace) && ($filter === null || isset($filter['csharpNamespace']))) {
			$output .= "\xaa\x02";
			$output .= Binary::encodeVarint(strlen($object->csharpNamespace));
			$output .= $object->csharpNamespace;
		}

		if (isset($object->javananoUseDeprecatedPackage) && ($filter === null || isset($filter['javananoUseDeprecatedPackage']))) {
			$output .= "\xb0\x02";
			$output .= Binary::encodeVarint((int)$object->javananoUseDeprecatedPackage);
		}

		if (isset($object->uninterpretedOption) && ($filter === null || isset($filter['uninterpretedOption']))) {
			foreach ($object->uninterpretedOption instanceof \Traversable ? $object->uninterpretedOption : (array)$object->uninterpretedOption as $k => $v) {
				$output .= "\xba\x3e";
				$buffer = UninterpretedOptionMeta::toProtobuf($v, $filter === null ? null : $filter['uninterpretedOption']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		return $output;
	}
335567
public static function filter($values, $filter, $map = null)
    {
        //
        $object = is_array($values) ? static::create($values, $map) : $values;
        $methods = static::getClassMethodsByPrefix($filter);

        //
        if (!is_object($object) || count($methods) == 0) {
            return $object;
        }

        //
        foreach ($object as $field => $value) {
            $compareWith = $filter.$field;

            foreach ($methods as $method) {
                if (preg_match('/^'.$method.'/i', $compareWith)) {
                    $object->{$field} = call_user_func([$object, $method], $value);
                }
            }
        }

        return $object;
    }
616455
public function sendByGroup($filter = [], $message = [])
    {
        $msg = array_merge(['filter' => $filter], $message);
        $msg['msgtype'] = array_keys($message)[0];

        return $this->http->jsonPost(self::API_SEND, $msg);

    }
325041
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->fileToGenerate) && ($filter === null || isset($filter['fileToGenerate']))) {
			foreach ($object->fileToGenerate instanceof \Traversable ? $object->fileToGenerate : (array)$object->fileToGenerate as $k => $v) {
				$output .= "\x0a";
				$output .= Binary::encodeVarint(strlen($v));
				$output .= $v;
			}
		}

		if (isset($object->parameter) && ($filter === null || isset($filter['parameter']))) {
			$output .= "\x12";
			$output .= Binary::encodeVarint(strlen($object->parameter));
			$output .= $object->parameter;
		}

		if (isset($object->protoFile) && ($filter === null || isset($filter['protoFile']))) {
			foreach ($object->protoFile instanceof \Traversable ? $object->protoFile : (array)$object->protoFile as $k => $v) {
				$output .= "\x7a";
				$buffer = FileDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['protoFile']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		return $output;
	}
465445
public static function toProtobuf($object, $filter = NULL)
	{
		$output = '';

		if (isset($object->name) && ($filter === null || isset($filter['name']))) {
			$output .= "\x0a";
			$output .= Binary::encodeVarint(strlen($object->name));
			$output .= $object->name;
		}

		if (isset($object->value) && ($filter === null || isset($filter['value']))) {
			foreach ($object->value instanceof \Traversable ? $object->value : (array)$object->value as $k => $v) {
				$output .= "\x12";
				$buffer = EnumValueDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['value']);
				$output .= Binary::encodeVarint(strlen($buffer));
				$output .= $buffer;
			}
		}

		if (isset($object->options) && ($filter === null || isset($filter['options']))) {
			$output .= "\x1a";
			$buffer = EnumOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']);
			$output .= Binary::encodeVarint(strlen($buffer));
			$output .= $buffer;
		}

		return $output;
	}