Checks if a custom message exists or returns the default
@param string $defMsg Default message of the filter
@param array $options Element filter Options
@return string
971917
private function checkMessage($defMsg, array $options) {
        if (is_array($options) && isset($options['message']))
            return $options['message'] ? $options['message'] : null;

        return $defMsg;
    }
332220
public function message($ruleOrMessage, $message = null)
    {
        if (1 === func_num_args()) {
            $rule = $this->lastRule;
            $message = $ruleOrMessage;
        } else {
            $rule = $ruleOrMessage;
        }

        $this->options['messages'][$this->lastKey][$rule] = $message;

        return $this;
    }
203694
protected function getDefaultErrorMessages()
    {
        $messages = [
            'message' => '{attribute} is invalid.',
            'messageDNS' => 'DNS record corresponding to {attribute} not found.',
            'messageLabelNumberMin' =>
                '{attribute} should consist of at least {labelNumberMin, number} labels separated by ' .
                '{labelNumberMin, plural, =2{dot} other{dots}}.',
            'messageLabelTooShort' => 'Each label of {attribute} should contain at least 1 character.',
            'messageNotString' => '{attribute} must be a string.',
            'messageTooShort' => '{attribute} should contain at least 1 character.',
        ];
        if ($this->enableIDN) {
            $messages['messageLabelStartEnd'] =
                'Each label of {attribute} should start and end with letter or number.' .
                ' The rightmost label of {attribute} should start with letter.';
            $messages['messageLabelTooLong'] = 'Label of {attribute} is too long.';
            $messages['messageTooLong'] = '{attribute} is too long.';
            if ($this->allowUnderscore) {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only letters, numbers, hyphens and underscores.';
            } else {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only letters, numbers and hyphens.';
            }
        } else {
            $messages['messageLabelStartEnd'] =
                'Each label of {attribute} should start and end with latin letter or number.' .
                ' The rightmost label of {attribute} should start with latin letter.';
            $messages['messageLabelTooLong'] = 'Each label of {attribute} should contain at most 63 characters.';
            $messages['messageTooLong'] = '{attribute} should contain at most 253 characters.';
            if ($this->allowUnderscore) {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only latin letters, numbers, hyphens and underscores.';
            } else {
                $messages['messageInvalidCharacter'] =
                    'Each label of {attribute} can consist of only latin letters, numbers and hyphens.';
            }
        }
        return $messages;
    }
656022
public function checkMessages(array $options = [])
    {
        $this->buildCall('/incoming-messages');
        $this->buildBody($options);

        $rawMessages = $this->getRequest()->json();

        return $this->makeMessages($rawMessages['Response']['Entries']);
    }
621276
public static function notNullText(
        $msg = '',
        $default = null,
        $noValidMessage = null,
        $attemptTimes = 3,
        $failCloseMessage = false
    ) {
        $prompter = new NotNullPrompter();

        static::prepareCallbackPrompter($prompter, $noValidMessage, $attemptTimes, $failCloseMessage);

        return $prompter->ask($msg, $default);
    }
303368
public function getFirstMessage($key, $default = null)
    {
        $messages = self::getMessage($key);
        if (is_array($messages) && count($messages) > 0) {
            return $messages[0];
        }

        return $default;
    }
1280309
protected function handleDefaults(ParsedMessage $parsedMessage)
    {
        if (!$parsedMessage->getFrom() && $this->defaults['from']['email']) {
            $parsedMessage->setFrom($this->defaults['from']['email'], $this->defaults['from']['name']);
        }

        if (!$parsedMessage->getTo() && $this->defaults['to']['email']) {
            $parsedMessage->addTo($this->defaults['to']['email'], $this->defaults['to']['name']);
        }

        if (!$parsedMessage->getCc() && $this->defaults['cc']['email']) {
            $parsedMessage->addCC($this->defaults['cc']['email'], $this->defaults['cc']['name']);
        }

        if (!$parsedMessage->getBcc() && $this->defaults['bcc']['email']) {
            $parsedMessage->addBcc($this->defaults['bcc']['email'], $this->defaults['bcc']['name']);
        }

        if (!$parsedMessage->getReplyTo() && $this->defaults['replyTo']) {
            $parsedMessage->setReplyTo($this->defaults['replyTo']);
        }

        if (!$parsedMessage->getSubject() && $this->defaults['subject']) {
            $parsedMessage->setSubject($this->defaults['subject']);
        }
    }
953303
public function message(array $config): string
    {
        if ($this->message) {
            return $this->message;
        }

        return trans('self-diagnosis::checks.locales_are_installed.message.missing_locales', [
            'locales' => $this->missingLocales->implode(PHP_EOL),
        ]);
    }
385248
public static function validText(
        $msg = '',
        $options = [],
        $default = null,
        $noValidMessage = null,
        $attemptTimes = 3,
        $failCloseMessage = false
    ) {
        $prompter = new ValidatePrompter();

        $prompter->setOptions($options);

        static::prepareCallbackPrompter($prompter, $noValidMessage, $attemptTimes, $failCloseMessage);

        return $prompter->ask($msg, $default);
    }
1182828
public function checkMessages(array $options = [])
    {
        $this->buildCall('/search/messages/'.$this->apiKey.'/'.$this->apiSecret);

        $this->buildBody($options);

        $rawMessages = json_decode($this->getRequest()->getBody()->getContents());

        return $this->makeMessages($rawMessages->items);
    }
98913
public function basicPublish( \AMQP\Message $msg, $options = array())
    {
        $default = array('exchange' => '', 'routing_key' => '', 'mandatory' => false, 'immediate' => false,
                         'ticket' => null);
        $options = array_merge($default, $options);
        $options['ticket'] = $this->getTicket($options['ticket']);
        $args = $this->frameBuilder->basicPublish($options);

        $this->sendMethodFrame(array(60, 40), $args);

        $this->connection->sendContent(
            $this->channelId, 60, 0,
            strlen($msg->body),
            $msg->serializeProperties(),
            $msg->body
        );
    }
127114
protected function parseAgnosticDsn(array $options)
    {
        if (isset($options['dsn']) && is_string($options['dsn'])) {
            $regex = '#^(?P<adapter>[^\\:]+)\\://(?:(?P<user>[^\\:@]+)(?:\\:(?P<pass>[^@]*))?@)?'
                   . '(?P<host>[^\\:@/]+)(?:\\:(?P<port>[1-9]\\d*))?/(?P<name>[^\?]+)(?:\?(?P<query>.*))?$#';
            if (preg_match($regex, trim($options['dsn']), $parsedOptions)) {
                $additionalOpts = [];
                if (isset($parsedOptions['query'])) {
                    parse_str($parsedOptions['query'], $additionalOpts);
                }
                $validOptions = ['adapter', 'user', 'pass', 'host', 'port', 'name'];
                $parsedOptions = array_filter(array_intersect_key($parsedOptions, array_flip($validOptions)));
                $options = array_merge($additionalOpts, $parsedOptions, $options);
                unset($options['dsn']);
            }
        }

        return $options;
    }
265689
private function prepareOptions(array $args, $defaultMask) {

        $options = ArrayHelper::get($args, "opts", []);

        $options["autoUnmask"]         = ArrayHelper::get($options, "autoUnmask", true);
        $options["removeMaskOnSubmit"] = ArrayHelper::get($options, "removeMaskOnSubmit", true);
        if (null !== $defaultMask) {
            $options["placeholder"] = preg_replace("/[^\ ][.]*/", "_", $defaultMask);
        }

        return $options;
    }
1125412
protected function getLocaleContext( array $msg )
	{
		$lcontext = clone $this->getContext();
		$manager = \Aimeos\MShop::create( $lcontext, 'locale' );

		$sitecode = ( isset( $msg['sitecode'] ) ? $msg['sitecode'] : 'default' );
		$localeItem = $manager->bootstrap( $sitecode, '', '', false, \Aimeos\MShop\Locale\Manager\Base::SITE_ONE );

		return $lcontext->setLocale( $localeItem );
	}
408836
private function getMessage()
    {
        $ret = '';
        // Filter good messages
        $goodTypes = [ValidationResult::TYPE_GOOD, ValidationResult::TYPE_INFO];
        $good = array_filter(
            $this->result->getMessages(),
            function ($val, $key) use ($goodTypes) {
                if (in_array($val['messageType'], $goodTypes)) {
                    return true;
                }
                return false;
            },
            ARRAY_FILTER_USE_BOTH
        );
        if (!empty($good)) {
            $ret .= "GOOD: " . implode('; ', array_column($good, 'message')) . " ";
        }

        // Filter bad messages
        $badTypes = [ValidationResult::TYPE_ERROR, ValidationResult::TYPE_WARNING];
        $bad = array_filter(
            $this->result->getMessages(),
            function ($val, $key) use ($badTypes) {
                if (in_array($val['messageType'], $badTypes)) {
                    return true;
                }
                return false;
            },
            ARRAY_FILTER_USE_BOTH
        );
        if (!empty($bad)) {
            $ret .= "BAD: " . implode('; ', array_column($bad, 'message'));
        }
        return $ret;
    }
1254064
public function getMessage($rule, $default = NULL)
    {
        $messages = $this->getMessages();
        if (isset($messages[$rule])) {
            return $messages[$rule];
        } else {
            return $default;
        }
    }
387675
private static function mergeDefaults(array $config)
    {
        return array_replace_recursive([
            'hostname'     => gethostname(),    # Hostname of the server
            'default_tags' => [],               # A key-value array with default tags for metrics and events
            'prefix'       => '',               # A prefix for the metrics
            'logger'       => [
                'instance' => null,             # A Psr\LoggerInterface instance
                'debug'    => false,            # If true, it will log debug messages from the monitor  
                'level'    => LogLevel::INFO,   # The level for debug message
                'metrics'  => false,            # If true, metrics will be sent trough the provided logger instance
                'events'   => false,            # If true, events will be sent trough the provided logger instance
            ],
            'datadog'      => [
                'metrics'  => false,            # If true, metrics will be sent trough the datadog agent
                'events'   => false,            # If true, events will be sent trough the datadog agent
                'host'     => null,             # The datadog agent host, if null the default will be used
                'port'     => null,             # The datadog agent port, if null the default will be used
            ],
        ], $config);
    }