HTTP REQUEST checker

@param string $id REQUEST key to check
@param int $filter Filter type - http://php.net/manual/en/filter.filters.sanitize.php
@param array $filterOptions Filter options
@return mixed boolean if no filter is set
515849
public function isRequest($id=false,$filter=null,$filterOptions=array())
		{
			if(!$id)
			{
				return (isset($_SERVER['REQUEST_METHOD']) && (strtoupper($_SERVER['REQUEST_METHOD']) == 'GET' OR strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')) ? true : false;
			}
			else
			{
				if(isset($_REQUEST[$id]))
				{
					return $filter ? filter_var($_REQUEST[$id],$filter,$filterOptions) : true;
				}
				else
				{
					return false;
				}
			}
		}
1153531
public function delete(array $filter, array $deleteOptions = [])
    {
        // Set statement of bulk object
        $bulk = $this->getBulk();
        $bulk->delete($filter, $deleteOptions);

        try {
            $response = $this->getInstance()->executeBulkWrite(
                $this->getParam('database') . '.' . $this->getCollection(),
                $bulk,
                $this->getWrite()
            );

        } catch (BulkWriteException $e) {
            new Exception('Unable to write in database');
        }

        return $response ?? false;
    }
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;
    }
70932
public function handle(FilterOptionInterface $filter, array $options)
    {
        if (count($options) === 0) {
            return $filter;
        }

        $validOptions = $filter->getValidOptions();

        $this->validateFilterOptions($options, $validOptions);
        $this->setFilterOptions($filter, $options, $validOptions);

        return $filter;
    }
1256997
function filter($data, $filter = null, $options = null, $falseOnFail = true)
    {
        if (is_array($data)) {
            // the $filter must be an array or a string to an array defined under app.filters.rules
            if (is_string($filter)) {
                if (($rules = Atomik::get("helpers.filters.rules.$filter", false)) === false) {
                    throw new AtomikException('When $data is an array, the filter must be an array of definition or a defination name in filter()');
                }
            } else {
                $rules = $filter;
            }
            
            $results = array();
            $messages = array();
            $validate = true;
            
            foreach ($rules as $field => $params) {
                if (isset($data[$field]) && is_array($data[$field])) {
                    if (($results[$field] = $this->filter($data[$field], $params)) === false) {
                        $messages[$field] = Atomik::get('helpers.filters.messages', array());
                        $validate = false;
                    }
                    continue;
                }
                
                $filter = FILTER_SANITIZE_STRING;
                $message = Atomik::get('helpers.filters.default_message', 'The %s field failed to validate');
                $required = false;
                $default = null;
                $label = $field;
                if (is_array($params)) {
                    // extracting information from the array
                    if (isset($params['message'])) {
                        $message = Atomik::delete('message', $params);
                    }
                    if (isset($params['required'])) {
                        $required = Atomik::delete('required', $params);
                    }
                    if (isset($params['default'])) {
                        $default = Atomik::delete('default', $params);
                    }
                    if (isset($params['label'])) {
                        $label = Atomik::delete('label', $params);
                    }
                    if (isset($params['filter'])) {
                        $filter = Atomik::delete('filter', $params);
                    }
                    $options = count($params) == 0 ? null : $params;
                } else {
                    $filter = $params;
                    $options = null;
                }
                
                if (!isset($data[$field]) && !$required) {
                    // field not set and not required, do nothing
                    continue;
                }
                
                if ((!isset($data[$field]) || $data[$field] == '') && $required) {
                    // the field is required and either not set or empty, this is an error
                    $results[$field] = false;
                    $message = Atomik::get('helpers.filters.required_message', 'The %s field must be filled');
                    
                } else if ($data[$field] === '' && !$required) {
                    // empty but not required, null value
                    $results[$field] = $default;
                    
                } else {
                    // normal, validating
                    $results[$field] = $this->filter($data[$field], $filter, $options);
                }
                
                if ($results[$field] === false) {
                    // failed validation, adding the message
                    $messages[$field] = sprintf($message, $label);
                    $validate = false;
                }
            }
            
            Atomik::set('helpers.filters.messages', $messages);
            return $validate || !$falseOnFail ? $results : false;
        }
        
        if (is_string($filter)) {
            if (in_array($filter, filter_list())) {
                // filter name from the extension filters
                $filter = filter_id($filter);
                
            } else if (preg_match('@/.+/[a-zA-Z]*@', $filter)) {
                // regexp
                $options = array('options' => array('regexp' => $filter));
                $filter = FILTER_VALIDATE_REGEXP;
                
            } else if (($callback = Atomik::get("helpers.filters.callbacks.$filter", false)) !== false) {
                // callback defined under app/filters/callbacks
                $filter = FILTER_CALLBACK;
                $options = $callback;
            } 
        }
        
        return filter_var($data, $filter, $options);
    }
826956
private function _check_filter($item, $filter): bool
  {
    if ( $filter ){
      if ( is_string($filter) ){
        return strtolower(substr(\is_array($item) ? $item['path'] : $item, - strlen($filter))) === strtolower($filter);
      }
      if ( is_callable($filter) ){
        return $filter($item);
      }
    }
    return true;
  }
1312887
public function filterAction(array $filter)
    {
        $this->checkStaticTemplateIsIncluded();

        $arguments = $this->request->getArguments();

        $filtertext = $this->arrayToFiltertext($filter);

        $arguments['filter'] = $filtertext;

        $this->redirect('dynamic', null, null, $arguments);
    }
922013
public function create($filterTypeAlias, $name = null, array $options = [])
    {
        $alias = strtolower($filterTypeAlias);

        if (!$this->filterChain->hasType($alias)) {
            throw new FilterCreatorException(sprintf('Given filter type alias "%s" does not exist.', $alias));
        }


        /** @var FilterInterface $filter */
        $filter = clone $this->filterChain->getType($alias);

        if (!($filter instanceof FilterInterface)) {
            // The filter must implement the bundles FilterInterface.
            throw new FilterCreatorException(sprintf(
                'Filter "%s" must implement Da2e\FiltrationBundle\Filter\Filter\FilterInterface interface.',
                get_class($filter)
            ));
        }

        $filter->setName($name === null ? $this->generateUniqueName($alias) : $name);

        if (count($options) > 0) {
            // Handle filter options if there are such.
            $this->filterOptionHandler->handle($filter, $options);
        }

        return $filter;
    }
683916
public function buildFilterRulesForUsedOnly($filter, $idList = [])
    {
        $builder = $this->connection->createQueryBuilder()
            ->select($this->getColName())
            ->from($this->getMetaModel()->getTableName())
            ->groupBy($this->getColName());

        if (!empty($idList)) {
            $builder
                ->where('id IN (:ids)')
                ->setParameter('ids', $idList, Connection::PARAM_STR_ARRAY);
        }

        $arrUsedValues = $builder->execute()->fetchAll(\PDO::FETCH_COLUMN);
        $arrUsedValues = \array_filter(
            $arrUsedValues,
            function ($value) {
                return !empty($value);
            }
        );

        $filter->addFilterRule(new StaticIdList($arrUsedValues));
    }
506929
public function setFromFilterId( models\ParentalControl\FilterPlanning $filterPlanning, $filterId) {
        $service = sprintf( self::API_PARENTAL_FILTER_PLANNING, $filterId);
        $rest = $this->getService( $service);
        $rest->PUT( $filterPlanning);

        return $rest->getResult( models\ParentalControl\FilterPlanning::class);
    }
311864
public function filter($key, $filter=null, $option=null) {
		if (is_int(strpos($key,'.'))) {
			list($key,$fkey) = explode('.',$key,2);
			if (!isset($this->relFilter[$key.'.']))
				$this->relFilter[$key.'.'] = array();
			$this->relFilter[$key.'.'][$fkey] = array($filter,$option);
		} else
			$this->relFilter[$key] = array($filter,$option);
		return $this;
	}
895326
static function PostData($name, $filter = FILTER_DEFAULT, $options = null)
    {
        return filter_input(INPUT_POST, $name, $filter, $options);
    }
761564
protected function callFilter($filter, $route, $request)
    {
        return $this->callRouteFilter(
            $filter['filter'], $filter['parameters'], $route, $request
        );
    }
18397
public function filter(ODataQueryFilterInterface $filter = NULL) {
        if (isset($filter)) {
            $this->setFilter($filter);
            return $this;
        }
        return $this->getFilter();
    }
943894
public static filteraction[] get_filtered(nitro_service service, String filter) throws Exception{
		filteraction obj = new filteraction();
		options option = new options();
		option.set_filter(filter);
		filteraction[] response = (filteraction[]) obj.getfiltered(service, option);
		return response;
	}
1221800
public function isPost($id=false,$filter=null,$filterOptions=array())
		{
			if(!$id)
			{
				return (isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') ? true : false;
			}
			else
			{
				if(isset($_POST[$id]))
				{
					return $filter ? filter_var($_POST[$id],$filter,$filterOptions) : true;
				}
				else
				{
					return false;
				}
			}
		}
506391
protected function checkRequestFilters()
	{
		$filterName = Yii::app()->getRequest()->getParam($this->saveFilterVar);
		if (!$filterName)
			return false;

		if (!count($this->filteredBy))
			return false;

		$key = $this->generateRegistryItemKey();
		if ($this->jsonStorage->getData($key, $this->registry))
			return false;

		$data = array('name' => $filterName);
		$data['options'] = array(get_class($this->model) => $this->filteredBy);
		$this->jsonStorage->setData($key, $data, $this->registry);

		Yii::app()->getController()->redirect($this->redirectRoute);
		return true;
	}