Get the messages for a wildcard key.

@param  string  $key
@param  string|null  $format
@return array
493033
protected function getMessagesForWildcardKey($key, $format)
    {
        return collect($this->messages)
                ->filter(function ($messages, $messageKey) use ($key) {
                    return Str::is($key, $messageKey);
                })
                ->map(function ($messages, $messageKey) use ($format) {
                    return $this->transform(
                        $messages, $this->checkFormat($format), $messageKey
                    );
                })->all();
    }
960143
private function getCacheKey(?string $format, array $context)
    {
        foreach ($context[self::EXCLUDE_FROM_CACHE_KEY] ?? $this->defaultContext[self::EXCLUDE_FROM_CACHE_KEY] as $key) {
            unset($context[$key]);
        }
        unset($context[self::EXCLUDE_FROM_CACHE_KEY]);
        unset($context['cache_key']); // avoid artificially different keys

        try {
            return md5($format.serialize([
                'context' => $context,
                'ignored' => $this->ignoredAttributes,
                'camelized' => $this->camelizedAttributes,
            ]));
        } catch (\Exception $exception) {
            // The context cannot be serialized, skip the cache
            return false;
        }
    }
836650
public function getMessages(string $key, array $errors = []): array
    {
        // when there is a template for the given key, return only this message.
        if (array_key_exists($key, $this->templates)) {

            return [$this->translate($this->templates[$key], ['attribute' => $key])];

        }

        // return one message for each rule which failed.
        return array_reduce($errors, function ($messages, $error) use ($key) {

            $rule = $error->getRule();
            $parameters = $error->getParameters();

            $template = $this->getTemplate($key, $rule);

            $message = $this->translate($template, array_merge($parameters, [
                'attribute' => $key,
            ]));

            return array_merge($messages, [$message]);

        }, []);
    }
11558
protected function getTranslatedMessages(array $messageKeys, $locale)
    {
        $translatedMessages = [];

        foreach ($messageKeys as $key) {
            $translation = Lang::get($key, [], $locale);

            if (is_array($translation)) {
                $flattened = $this->flattenTranslations($translation, $key.'.');
                $translatedMessages = array_merge($translatedMessages, $flattened);
            } else {
                $translatedMessages[$key] = $translation;
            }
        }

        return $translatedMessages;
    }
671481
public function getMessages($key = null)
    {
        if (null !== $key) {
            return $this->flash->getMessage($key);
        }

        return $this->flash->getMessages();
    }
423608
public static function collate($array, $key, $wildcard = null)
    {
        // If no wildcard set or the wildcard is not in the key
        if (null === $wildcard || strpos($key, $wildcard) === false) {
            return static::has($array, $key) ? [$key => static::get($array, $key)] : [];
        }

        $pattern  = '';
        $segments = explode('.', $key);
        while (($segment = array_shift($segments)) !== null) {
            // If we have run out of arrays to look into, stop looking
            if (!Arr::accessible($array)) {
                return [];
            }

            // If this segment is a wildcard
            if ($segment === $wildcard) {
                $values = [];
                foreach (array_keys($array) as $attr) {
                    $subKey = implode('.', array_merge([$attr], $segments));
                    foreach (static::collate($array, $subKey, $wildcard) as $attrKey => $value) {
                        $values[$pattern . $attrKey] = $value;
                    }
                }

                return $values;
            }
            if (Arr::exists($array, $segment)) {
                $array = $array[$segment];
            } else {
                return [];
            }

            $pattern .= $segment . '.';
        }

        return [$key => $array];
    }
46742
public function read(string $key): array
    {
        return $this->useRedis(function($resource, $redis) use($key){
            $result = $redis->hget($this->getStoreKey(), $key);
            return $result ? $result : [];
        });
    }
1136870
public function getMessageDefaults($key = null)
    {
        if (is_null($key)) {
            return $this->messageDefaults;
        }

        if (isset($this->messageDefaults[$key])) {
            return $this->messageDefaults[$key];
        }
    }
767929
static function get($key = 'all', $format = false)
    {
        if (isset(self::$stop[$key])){
            if ($format){
                return array(
                    'time' => sprintf('%0.8f s', self::$stop[$key]['time']),
                    'memory' => sprintf('%0.3f Mb', self::$stop[$key]['memory'] / 1048576),
                    'memory_max' => sprintf('%0.3f Mb', self::$stop[$key]['memory_max'] / 1048576),
                );
            }else{
                return self::$stop[$key];
            }
        }
        return null;
    }
142366
public static function get($key, $params = array()) {
        if (static::$message === NULL) {
            static::setLanguage('en');
        }

        $rs = isset(static::$message[$key]) ? static::$message[$key] : $key;

        $names = array_keys($params);
        $names = array_map(array('\\PhalApi\\Translator', 'formatVar'), $names);

        return str_replace($names, array_values($params), $rs);
    }
186354
public function getKeys($pattern = null)
    {
        $keys = $this->get('__stored_keys__', []);
        if (is_null($pattern)) {
            return $keys;
        }

        $matches = [];
        $pattern = $this->_normalizePattern($pattern);
        foreach ($keys as $key) {
            if (preg_match($pattern, $key)) {
                $matches[] = $key;
            }
        }

        return $matches;
    }
620180
public function read(string $format = null) : string
    {
        $input = array_shift($this->stack);
        if (isset($format, $input)) {
            $input = sprintf($format, $input);
        }
        return $input ?? '';
    }
1246538
private function getJsonApiCacheKey(?string $format, array $context)
    {
        try {
            return md5($format.serialize($context));
        } catch (\Exception $exception) {
            // The context cannot be serialized, skip the cache
            return false;
        }
    }
315887
public function getMessageData($key)
    {
        if ($this->{$key}) {
            return $this->{$key};
        }

        $data_key = str_replace(['text_body', 'html_body'], ['txt_path', 'html_path'], $key);

        $data = $this->retrieveMessageData($data_key);

        if (!$data) {
            return '';
        }

        $this->{$key} = $data;

        return $data;
    }
963873
protected function transform($messages, $format, $messageKey)
    {
        $messages = (array) $messages;

        // We will simply spin through the given messages and transform each one
        // replacing the :message place holder with the real message allowing
        // the messages to be easily formatted to each developer's desires.
        foreach ($messages as $key => &$message) {
            $replace = [':message', ':key'];

            $message = str_replace($replace, [$message, $messageKey], $format);
        }

        return $messages;
    }
347991
protected function getConditionsFromKey($key)
    {
        if (is_int($key) || ctype_digit($key)) {
            return array(self::MATCH_USERGROUP_ID => $key);
        }
        return array(self::MATCH_CONTENT_REMOTE_ID => $key);
    }
494895
public function get_errors($key = null, string $format = ':message'): array
    {
        return $this->validation->get_errors($key, $format);
    }