Get terms with conditions
@param array $args
@return array
511955
public static function getWhere($args = array())
    {
        $instance = Term\Factory::create(get_called_class());

        // Allow sorting both by core fields and custom fields
        // See: http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
        $default_args = array(
            'orderby' => $instance->getDefaultOrderBy(),
            'order' => $instance->getDefaultOrder(),
            'hide_empty' => false, // Note: This goes against a WordPress get_terms default. But this seems more practical.
        );

        $criteria = array_merge($default_args, $args);

        // Custom ordering
        $orderby = null;
        $order = null;
        $wordpress_sortable_fields = array('id', 'name', 'count', 'slug', 'term_group', 'none');
        if (array_key_exists('orderby', $criteria) && !in_array($criteria['orderby'], $wordpress_sortable_fields)) {
            $orderby = $criteria['orderby'];
            $order = (array_key_exists('order', $criteria))
                ? strtoupper($criteria['order'])
                : 'ASC';
            unset($criteria['orderby']);
            unset($criteria['order']);
        }

        $criteria['taxonomy'] = $instance->getTaxonomyKey();
        $terms = Term\Factory::createMultiple(get_terms($criteria));

        // We might be done
        if (!Arr::iterable($terms)) {
            return $terms;
        }
        if (!$orderby) {
            return $terms;
        }

        // Custom sorting that WordPress can't do
        $field = $instance->getField($orderby);

        // Make sure we're sorting numerically if appropriate
        // because WordPress is storing strings for all vals
        if ($field['type'] === 'number') {
            foreach ($terms as &$term) {
                if (!isset($term->$orderby)) {
                    continue;
                }
                if ($term->$orderby === '') {
                    continue;
                }

                $term->$orderby = (float) $term->$orderby;
            }
        }

        // Sorting
        $sort_flag = ($field['type'] === 'number') ? SORT_NUMERIC : SORT_STRING;
        $terms = Collection::sortBy($terms, $orderby, $sort_flag);
        if (strtoupper($order) === 'DESC') {
            $terms = array_reverse($terms, true);
        }

        // Convert back to string as WordPress stores it
        if ($field['type'] === 'number') {
            foreach ($terms as &$term) {
                if (!isset($term->$orderby)) {
                    continue;
                }
                if ($term->$orderby === '') {
                    continue;
                }

                $term->$orderby = (string) $term->$orderby;
            }
        }

        return $terms;
    }
171137
public function get_terms( $taxonomy = '', $args = array() ) {
		if ( isset( $this->{$taxonomy} ) && empty( $args ) ) {
			return $this->{$taxonomy};
		} else {
			$name = $taxonomy . '_' . md5( json_encode( $args ) );
			if ( isset( $this->{$name} ) ) {
				return $this->{$name};
			}
			$data          = \wp_get_post_terms( $this->id(), $taxonomy, $args );
			$this->{$name} = $data;
			return $data;
		}
	}
478
public function find_subcommand( &$args ) {
		$name = array_shift( $args );

		$subcommands = $this->get_subcommands();

		if ( ! isset( $subcommands[ $name ] ) ) {
			$aliases = self::get_aliases( $subcommands );

			if ( isset( $aliases[ $name ] ) ) {
				$name = $aliases[ $name ];
			}
		}

		if ( ! isset( $subcommands[ $name ] ) ) {
			return false;
		}

		return $subcommands[ $name ];
	}
1255874
public function getAll($sql, array $args = [])
    {
        $result = $this->query($sql, $args);
        
        if (!$result) {
            return [];
        }

        $rows = $result->fetch_all(MYSQLI_ASSOC);
        
        return $rows;
    }
492427
private function parse_args($args = [])
    {
        $args['NAMESPACE'] = '';

        $class_name = $this->sanitise_filename($args['CLASSNAME']);

        if ($this->is_nested_directory($class_name)) {
            $parts = \explode('\\', $class_name);
            $class = \array_pop($parts);

            $args['NAMESPACE'] = '\\' . \implode('\\', $parts);
            $args['CLASSNAME'] = $class;
        }

        return $args;
    }
1279522
public static function getByMultiple($conditions, $args = array())
    {
        if (!Arr::iterable($conditions)) {
            return self::getWhere($args, $load_terms);
        }

        // Extract number if passed in $args
        // because we don't want to prematurely restrict the result set.
        $number = (array_key_exists('number', $args))
            ? $args['number']
            : null;
        unset($args['number']);

        // First, get all the post_ids
        $term_ids = array();
        foreach ($conditions as $k => $condition) {
            // Conditions can have numeric or named keys:
            // ['key1', 'val1', '=']
            // ['key'=>'foo', 'val'=>'bar', '=']
            $condition_values = array_values($condition);
            $key = (array_key_exists('key', $condition)) ? $condition['key'] : $condition_values[0];
            $value = (array_key_exists('value', $condition)) ? $condition['value'] : $condition_values[1];

            // Make sure we have a compare
            $compare = '=';
            if (array_key_exists('compare', $condition)) {
                $compare = $condition['compare'];
            } elseif (array_key_exists(2, $condition_values)) {
                $compare = $condition_values[2];
            }

            // Get the posts from getBy
            // Trying to replicate getBy's logic could be significant
            // b/c it handles both core and meta fields
            $terms = self::getBy($key, $value, $compare, $args);
            if (!Arr::iterable($terms)) {
                continue;
            }

            // Using array_intersect here gives us the AND relationship
            // array_merge would give us OR
            $new_term_ids = Collection::pluck($terms, 'term_id');
            $new_term_ids = array_map('intval', $new_term_ids);
            $term_ids = (Arr::iterable($term_ids))
                ? array_intersect($term_ids, $new_term_ids)
                : $new_term_ids;
            $term_ids = array_unique($term_ids);

            // After the first conditional, we can start modifying the args
            // to restrict results to previously matched posts.
            //
            // Effectively, this also means that when calling this method
            // you should put conditions you expect to be more restrictive
            // earlier in the conditionals array.
            $args['include'] = $term_ids;
        }

        // Reapply numberposts now that we have our desired post_ids
        if (!is_null($number)) {
            $args['number'] = $number;
        }

        // TODO This should probably use getWhere
        //      but it seems like getWhere may not work with the ordering
        unset($args['include']);
        return (Arr::iterable($term_ids))
            ? self::getBy('term_id', $term_ids, 'in', $args)
            : array();
    }
1263166
public function arguments(array $arguments = [])
    {
        if (empty($arguments)) {
            return $this->arguments;
        }

        foreach ($arguments as $key => $value) {
            if (!isset($this->requirements[$key])) {
                $this->arguments[$key] = $value;
                continue;
            }

            $this->assertArgumentValue($key, $this->requirements[$key], $value);
            $this->arguments[$key] = $value;
        }

        return $this->arguments;
    }
813130
public static function InputTwo($args) 
    {
      $one = Ensure::Input($args[0]);
      $two = Ensure::Input($args[1]);

      return array(
        0 => $one,
        1 => $two
      );
    }
797490
protected function normalizeArgs(array $args)
    {
        $args += [
            'numTranslators' => '',
            'limitToLocale' => '',
        ];
        $valn = $this->app->make(Numbers::class);
        $normalized = [
            'numTranslators' => $valn->integer($args['numTranslators'], 1) ? (int) $args['numTranslators'] : null,
            'allTranslations' => empty($args['allTranslations']) ? 0 : 1,
            'limitToLocale' => '',
        ];
        if ($args['limitToLocale'] !== '') {
            $locale = $this->app->make(LocaleRepository::class)->findApproved($args['limitToLocale']);
            if ($locale !== null) {
                $normalized['limitToLocale'] = $locale->getID();
            }
        }

        return $normalized;
    }
79020
protected function parseAttributes( array $args )
	{
		if( empty( $args['attributes'] )) {
			return [];
		}

		$attributes = (array) $args['attributes'];

		foreach( $attributes as $key => $value ) {
			if( is_string( $key ))continue;
			unset( $attributes[ $key ] );
			if( !isset( $attributes[ $value ] )) {
				$attributes[ $value ] = '';
			}
		}

		return $attributes;
	}
156229
private function getDefinitionsFromArguments(array $arguments)
    {
        $definitions = array();
        foreach ($arguments as $argument) {
            if (is_array($argument)) {
                $definitions = array_merge($definitions, $this->getDefinitionsFromArguments($argument));
            } elseif ($argument instanceof Definition) {
                $definitions = array_merge(
                    $definitions,
                    $this->getInlinedDefinitions($argument),
                    array($argument)
                );
            }
        }

        return $definitions;
    }
805998
public function get_conditions(array $conditions, array $cfg = [], bool $is_having = false): string
  {
    $res = '';
    if ( isset($conditions['conditions'], $conditions['logic']) ){
      $logic = isset($conditions['logic']) && ($conditions['logic'] === 'OR') ? 'OR' : 'AND';
      foreach ( $conditions['conditions'] as $key => $f ){
        if ( \is_array($f) && isset($f['logic']) && !empty($f['conditions']) ){
          if ( $tmp = $this->get_conditions($f, $cfg, $is_having) ){
            $res .= (empty($res) ? '(' : PHP_EOL."$logic ").$tmp;
          }
        }
        else if ( isset($f['operator'], $f['field']) ){
          $field = $f['field'];
          if ( !array_key_exists('value', $f) ){
            $f['value'] = false;
          }
          $is_number = false;
          $is_null = true;
          $is_uid = false;
          $is_date = false;
          $model = null;
          if ( isset($cfg['available_fields'][$field]) ){
            $table = $cfg['available_fields'][$field];
            $column = $this->col_simple_name($cfg['fields'][$field] ?? $field);
            if ( isset($cfg['models'][$table]['fields'][$column]) ){
              $model = $cfg['models'][$table]['fields'][$column];
              $res .= (empty($res) ?
                  '(' :
                  " $logic ").(
                !empty($cfg['available_fields'][$field]) ?
                  $this->col_full_name($cfg['fields'][$field] ?? $field, $cfg['available_fields'][$field], true).' ' :
                  $this->col_simple_name($column, true)
                );
            }
            else{
              $res .= (empty($res) ? '(' : PHP_EOL."$logic ").$field.' ';
            }
            if ( !empty($model) ){
              $is_null = (bool)$model['null'];
              if ( $model['type'] === 'binary' ){
                $is_number = true;
                if ( ($model['maxlength'] === 16) && $model['key'] ){
                  $is_uid = true;
                }
              }
              else if ( \in_array($model['type'], self::$numeric_types, true) ){
                $is_number = true;
              }
              else if ( \in_array($model['type'], self::$date_types, true) ){
                $is_date = true;
              }
            }
            else if ( $f['value'] && \bbn\str::is_uid($f['value']) ){
              $is_uid = true;
            }
          }
          else{
            $res .= (empty($res) ? '(' : " $logic ").$field.' ';
          }
          switch ( strtolower($f['operator']) ){
            case 'like':
              $res .= 'LIKE ?';
              break;
            case 'not like':
              $res .= 'NOT LIKE ?';
              break;
            case 'eq':
            case '=':
            case 'is':
              if ( isset($f['exp']) ){
                $res .= '= '.$f['exp'];
              }
              else if ( $is_uid || $is_number ){
                $res .= '= ?';
              }
              else{
                $res .= 'LIKE ?';
              }
              break;
            case 'neq':
            case '!=':
            case 'isnot':
              if ( isset($f['exp']) ){
                $res .= '!= '.$f['exp'];
              }
              else if ( $is_uid || $is_number ){
                $res .= '!= ?';
              }
              else{
                $res .= 'NOT LIKE ?';
              }
              break;

            case 'doesnotcontains':
              $res .= 'NOT LIKE '.($f['exp'] ?? '?');
              break;

            case 'endswith':
            case 'startswith':
            case 'contains':
              $res .= 'LIKE '.($f['exp'] ?? '?');
              break;

            case 'gte':
            case '>=':
              if ( isset($f['exp']) ){
                $res .= '>= '.$f['exp'];
              }
              else{
                $res .= '>= ?';
              }
              break;

            case 'gt':
            case '>':
              if ( isset($f['exp']) ){
                $res .= '> '.$f['exp'];
              }
              else{
                $res .= '> ?';
              }
              break;

            case 'lte':
            case '<=':
              if ( isset($f['exp']) ){
                $res .= '<= '.$f['exp'];
              }
              else{
                $res .= '<= ?';
              }
              break;

            case 'lt':
            case '<':
              if ( isset($f['exp']) ){
                $res .= '< '.$f['exp'];
              }
              else{
                $res .= '< ?';
              }
              break;

            /** @todo Check if it is working with an array */
            case 'isnull':
              $res .= $is_null ? 'IS NULL' : " = ''";
              break;

            case 'isnotnull':
              $res .= $is_null ? 'IS NOT NULL' : " != ''";
              break;

            case 'isempty':
              $res .= $is_number ? '= 0' : "LIKE ''";
              break;

            case 'isnotempty':
              $res .= $is_number ? '!= 0' : "NOT LIKE ''";
              break;

            case 'doesnotcontain':
              $res .= $is_number ? '!= ?' : 'NOT LIKE ?';
              break;

            case 'contains':
            default:
              $res .= $is_number ? '= ?' : 'LIKE ?';
              break;
          }
        }
      }
      if ( !empty($res) ){
        $res .= ')'.PHP_EOL;
      }
    }
    return $res;
  }
537469
private function getArguments($argsNumber, $arguments)
    {
        if ($argsNumber == 1 && is_string($arguments)) {
            return [$arguments];
        } elseif ($argsNumber === count($arguments)) {
            return $arguments;
        }

        for ($i = 0; $i < $argsNumber; $i++) {
            if (array_key_exists($i, $arguments)) {
                $args[] = $arguments[$i];
                continue;
            }

            return $args;
        }

        return [];
    }
897938
public function filter($args)
    {
        $result = $this->data->models;
        return $this->data->copy(array_filter($result, $this->filter_function($args)));
    }
1191965
protected function prepareCondition(array $args = []): string
    {
        $condition = array_shift($args);
        foreach ($args as &$value) {
            if (\is_array($value)) {
                $replace = implode(',', array_fill(0, \count($value), ':REPLACE:'));
                $condition = preg_replace('/\?/', $replace, $condition, 1);
                foreach ($value as $part) {
                    $this->setParam(null, $part);
                }
            } else {
                $this->setParam(null, $value);
            }
        }
        unset($value);

        $condition = preg_replace('/(\:REPLACE\:)/', '?', $condition);

        return $condition;
    }
515806
public static function arguments(array $args) : array
    {
        putenv("CODGER_DRY=1");
        foreach ($args as $key => $value) {
            if ($value === '-w') {
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-o') {
                putenv("CODGER_OVERWRITE=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-d') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_DUMP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-s') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_SKIP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
        }
        return array_values($args);
    }
590006
protected function getServiceByArgs($args) {
		$args = $this->normalizeArgs($args);
		$id   = $this->getIdByArgs($args);
		$args = $this->processArgs($args);
			
		if (! isset($this->servicesByArgs[$id])) {
			$this->servicesByArgs[$id] = $this->initService($args);
		}

		return $this->servicesByArgs[$id];
	}