Shortcut for searching.

@param string $string
@param string $resources

@return array
425811
public function search(string $string, string $resources = ''): array
    {
        $query = $this->getRepository('Search')
            ->query()
            ->setParameter('query', $string);
        if ($resources) {
            $query->setParameter('resources', \mb_strtolower($resources));
        }

        return $query->find();
    }
1034521
function hash($string) {
		$options = [];
		if (!is_null($this->cost))
			$options	= ['cost'	=> $this->cost];
		
		return password_hash($string, PASSWORD_DEFAULT, $options);
	}
491027
public static function get_string_from_input($string) {
        $string = trim($string);

        if (preg_match('|^([a-zA-Z][a-zA-Z0-9\.:/_-]*),([a-zA-Z][a-zA-Z0-9\.:/_-]*)$|', $string, $matches)) {
            if ($matches[2] === 'moodle') {
                $matches[2] = 'core';
            }

            if (get_string_manager()->string_exists($matches[1], $matches[2])) {
                $string = get_string($matches[1], $matches[2]);
            }
        }

        return $string;
    }
564356
public function search(string $search, $properties = null, array $options = null)
    {
        return $this->__call('search', [$search, $properties, $options]);
    }
924671
public function fetchFromString($string ="", $data = [])
    {
        $data = array_merge($this->defaultVariables, $data);

        return $this->environment->createTemplate($string)->render($data);
    }
1164094
protected function parseString($string) {
        $matches = [];

        if (preg_match_all($this->regex, $string, $result) !== false) {
            $matches = $result[0];
        }

        return $matches;
    }
386503
private function scanNextType($string)
    {
        foreach ($this->patterns as $type => $pattern) {
            if (preg_match('/^(' . $pattern . ')/sS', $string, $matches) === 1) {
                return [
                    'type'   => $type,
                    'match'  => $matches[1],
                    'length' => strlen($matches[1]),
                ];
            }
        }

        return null;
    }
787723
private function parseQuery($string)
    {
        $return = array();
        $parts = explode("&", $string);
        foreach ($parts as $part) {
            list($key, $value) = explode('=', $part, 2);
            $value = urldecode($value);
            if (isset($return[$key])) {
                if (!is_array($return[$key])) {
                    $return[$key] = array($return[$key]);
                }
                $return[$key][] = $value;
                continue;
            }
            $return[$key] = $value;
        }
        return $return;
    }
468338
public function findCacheByString(string $string, int $siteId = null)
    {

        // Check if already in cache
        if ($this->isCachedByString($string, $siteId)) {
            return $this->cacheByString[$siteId][$string];
        }

        return null;
    }
821428
private function getStyleStack($string)
    {
        if (preg_match_all(static::REGEX_FORMAT, $string, $matches)) {
            foreach ($matches[1] as $grouping) {
                if (preg_match_all(static::REGEX_STYLE_ITEM, $grouping, $styles)) {
                    foreach ($styles[0] as $style) {
                        yield $style;
                    }
                } else {
                    yield static::STYLE_RESET;
                }
            }
        }
        return;
    }
759917
private function _resolveKeyString($string) {
        $string     = strtolower($string);
        $properties = array(
                       'fifths' => 0,
                       'mode'   => 'major',
                      );

        // we could use math, but that's just showing off and it wouldn't be faster
        $keys = array(
                 'major' => array(
                             'c-' => -7,
                             'g-' => -6,
                             'd-' => -5,
                             'a-' => -4,
                             'e-' => -3,
                             'b-' => -2,
                             'f'  => -1,
                             'c'  => 0,
                             'g'  => 1,
                             'd'  => 2,
                             'a'  => 3,
                             'e'  => 4,
                             'b'  => 5,
                             'f+' => 6,
                             'c+' => 7,
                             'd+' => null,
                             'e+' => null,
                             'f-' => null,
                             'g+' => null,
                             'a+' => null,
                             'b+' => null,
                            ),
                 'minor' => array(
                             'a-' => -7,
                             'e-' => -6,
                             'b-' => -5,
                             'f'  => -4,
                             'c'  => -3,
                             'g'  => -2,
                             'd'  => -1,
                             'a'  => 0,
                             'e'  => 1,
                             'b'  => 2,
                             'f+' => 3,
                             'c+' => 4,
                             'g+' => 5,
                             'd+' => 6,
                             'a+' => 7,
                             'c-' => null,
                             'd-' => null,
                             'e+' => null,
                             'f-' => null,
                             'g-' => null,
                             'b+' => null,
                            ),
                );

        preg_match('/([A-Ga-g+#-b]+?)(.*)/', $string, $matches);
        $chroma = $matches[1];
        $inmode = $matches[2];

        $inmode = trim($inmode);

        $modes = array(
                  'major' => array(
                              'maj',
                              'major',
                              '',
                             ),
                  'minor' => array(
                              'min',
                              'minor',
                             ),
                 );

        foreach ($modes as $modeName => $modeAliases) {
            if (in_array($inmode, $modeAliases)) {
                $properties['mode'] = $modeName;
            }
        }

        $properties['fifths'] = $keys[$properties['mode']][$chroma];

        $this->properties = $properties;

    }
131187
public function userAutocompleteAction($string)
    {
        $manager = $this->getSiteManager();
        $account = $this->getCurrentUser();

        if (!$manager->getAccess()->userIsWebmaster($account) && !$this->isGranted(Access::PERM_USER_MANAGE_ALL)) {
            throw $this->createAccessDeniedException();
        }

        $database = $this->getDatabaseConnection();
        $q = $database
            ->select('users', 'u')
            ->fields('u', ['uid', 'name'])
            ->condition('u.name', '%' . $database->escapeLike($string) . '%', 'LIKE')
            ->condition('u.uid', [0, 1], 'NOT IN')
            ->orderBy('u.name', 'asc')
            ->range(0, 16)
            ->addTag('ucms_user_access')
        ;

        $suggest = [];

        foreach ($q->execute()->fetchAll() as $record) {
            $key = $record->name . ' [' . $record->uid . ']';
            $suggest[$key] = check_plain($record->name);
        }

        return new JsonResponse($suggest);
    }
66596
public function search($searchStr)
    {
        $conditions = [];

        $parsedStr = $this->parseSearchStr($searchStr);

        foreach ($this->searchable() as $column) {
            $conditions[] = $column.' like "'.$parsedStr.'"';
        }

        $method = $this->searchOperator.'Raw';
        $query  = $this->query()->{$method}('('.join(' OR ', $conditions).')');

        if ($this->sort) {
            $this->applySort($query, $searchStr);
        }

        return $query;
    }
1308814
public function tokenize($string)
    {
        if(!$this->length) {
            return array(substr($string, $this->startPosition));
        } else {
            return array(substr($string, $this->startPosition, $this->length));
        }
    }
23537
public function loadString(&$string): array
    {
        /** @noinspection CallableParameterUseCaseInTypeContextInspection */
        $string = $this->unwrap($string);
        $this->rawSegments = $string;

        return $this->parse($string);
    }
123988
public String[] getLocalizedResourceArray(String namespace, String resourceId) throws Exception {
        Class r = Class.forName(namespace + "$string");
        Field f = r.getField(resourceId);
        return getCurrentActivity().getResources().getStringArray(f.getInt(f));
    }
1335629
protected function getStringQueryParameters($string)
    {
        $query = parse_url($string, PHP_URL_QUERY);

        $params = [];
        if ($query) parse_str($query, $params);

        return $params;
    }