Creates a string on phrases.

@param array $fields
@param array & $messagesToRegister

@return string
10584
protected function getLangPhrases(array $labels, array &$messagesToRegister)
    {
        $messages = [];

        foreach ($labels as $label) {
            if (!$this->isMessageExists($label->localeGroup, $label->lang) || $this->option('force')) {
                $messages[] = $this->getMessage($label);
                $messagesToRegister[$label->localeGroup] = $label->text;
            }
        }

        $glue = "," . PHP_EOL;

        return !isset($messages[0]) ? '' : implode($glue, $messages) . $glue;
    }
360530
public function stringify(array $fields): string
    {
        $normalized = $this->normalizerFormatter->format($fields);
        $prettyPrintFlag = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : 128;

        $hasSecondDimension = count(array_filter($normalized, 'is_array'));
        $hasNonNumericKeys = !count(array_filter(array_keys($normalized), 'is_numeric'));

        return $hasSecondDimension || $hasNonNumericKeys
            ? json_encode($normalized, $prettyPrintFlag|JSON_UNESCAPED_UNICODE)
            : json_encode($normalized, JSON_UNESCAPED_UNICODE);
    }
607468
public static function fromString(string $fieldListString, string $delimiter = ',') : TrigramPhraseFields
    {
        return self::initializeFromString($fieldListString, $delimiter);
    }
1353777
public function orderBy($fields)
    {
        if (!is_array($fields)) {
            $fields = explode(",", $fields);
        }

        $orderBy = "";

        foreach ($fields as $field) {
            if (!$field = trim($field)) {
                continue;
            }
            if (!$orderBy) {
                $orderBy = "ORDER BY ";
            } else {
                $orderBy .= ", ";
            }

            if (strpos($field, " ")) {
                $orderBy .= $field;
            } else {
                $orderBy .= $this->quoteField($field);
            }
        }

        return $orderBy;
    }
1079380
public function getTitleFields(array $fields)
    {
        $fields = array_map(function ($field) {
            if (str_contains($field, '.')) {
                return object_get($this, $field); // this acts as a delimiter, which we can replace with /
            } else {
                return $this->{$field};
            }
        }, $fields);

        return $fields;
    }
1263964
protected function generateJoin(array &$fields)
    {
        $annotations = $this->annotations['class'];
        $props = $this->annotations['properties'];
        $table = '';
        foreach (['Require' => '', 'Include' => 'LEFT '] as $type => $join) {
            if (isset($annotations[$type])) {
                foreach ($annotations[$type] as $local => $joinCond) {
                    if (is_numeric($local)) {
                        foreach ($joinCond as $local => $joinCond) {
                        }
                    }
                    // Hack to make the annotationParser recurse.
                    $joinCond = AnnotationParser::getAnnotations(
                        '/** @joinCond '.implode(', ', $joinCond).' */'
                    )['joincond'];
                    $table .= sprintf(
                        ' %1$sJOIN %2$s ON ',
                        $join,
                        $local
                    );
                    $conds = [];
                    foreach ($joinCond as $ref => $me) {
                        if ($me == '?') {
                            $conds[] = sprintf(
                                "%s.%s = $me",
                                $local,
                                $ref
                            );
                        } else {
                            $conds[] = sprintf(
                                "%s.%s = %s.%s",
                                $local,
                                $ref,
                                $this->identifier,
                                $me
                            );
                        }
                    }
                    $table .= implode(" AND ", $conds);
                }
            }
        }
        foreach ($fields as &$field) {
            $name = str_replace("{$this->identifier}.", '', $field);
            if (isset($props[$name]['From'])) {
                $field = sprintf(
                    '%s %s',
                    $props[$name]['From'],
                    $name
                );
            }
        }
        return $table;
    }
1119444
public function load(array $fields)
    {
        $this->quote->setStoreId($this->storeManager->getStore()->getId());

        foreach ($fields as $rawFields) {
            $method = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($rawFields);
            $this->log->debug('Starting method ' . $method);
            $this->{$method}();
            $this->log->debug('Finished method ' . $method);
        }

        return $this->quote;
    }
24829
public function createSms($body, array $recipients, $sender)
    {
        $sms = $this->createEmptySms();
        $sms->setBody($body);
        $sms->setRecipients($recipients);
        $sms->setSender($sender);

        return $sms;
    }
567652
public function createInserts(string $tableName, array $fields, array $rows): string
    {
        $sql = "INSERT " . "INTO {$tableName} (" . implode(',', $fields) . ') VALUES ';
        foreach ($rows as $row) {
            $sql .= '(' . implode(',', $row) . '),';
        }
        return trim($sql, ',');
    }
936467
public static function constructStringFromArguments(array $arguments): string
    {
        $result = '';
        foreach ($arguments as $argument) {
            $result .= ' ' . $argument;
        }

        return $result;
    }
181591
public static function makeFromShorthand(array $data = array(), array $fields = array()) {
        /** @type \Titon\Utility\Validator $obj */
        $obj = new static($data);

        foreach ($fields as $field => $data) {
            $title = $field;

            // Convert to array
            if (is_string($data)) {
                $data = array('rules' => $data);

            } else if (!is_array($data)) {
                continue;

            } else if (Hash::isNumeric(array_keys($data))) {
                $data = array('rules' => $data);
            }

            // Prepare for parsing
            if (isset($data['title'])) {
                $title = $data['title'];
            }

            if (is_string($data['rules'])) {
                $data['rules'] = explode('|', $data['rules']);
            }

            $obj->addField($field, $title);

            foreach ($data['rules'] as $ruleOpts) {
                $shorthand = self::splitShorthand($ruleOpts);

                $obj->addRule($field, $shorthand['rule'], $shorthand['message'], $shorthand['options']);
            }
        }

        return $obj;
    }
1059730
public static function serializeTags(array $tags)
    {
        if (empty($tags))
            return '';

        self::validateTags($tags);
        $tagstrs = array();
        foreach ($tags as $tag)
            $tagstrs[] = $tag->toString(true);

        return implode(';', $tagstrs);
    }
564159
protected function registerMessages(array $messages, $language)
    {
        if (count($messages) > 0) {
            $this->getTranslator()->addLines($messages, $language);
        }

        return $this;
    }
213326
private function formatStructForApi(array $fields)
    {
        $fFields = [];

        foreach ($fields as $key => $value) {
            $fFields[$key] = $this->formatValueForApi($value);
        }

        return ['fields' => $fFields];
    }
983205
protected function formatMessages($messages, $format, $type = '')
    {

        if ($format === self::Format_Array) {
            $result = $messages;
        } else {
            $result = array();
            foreach ($messages as $message) {
                if (is_array($message)) {
                    $messagePart = "{$message['code']}: ";
                    $messagePart .= $this->t($message['message']);
                    if ($message['codetag']) {
                        $messagePart .= " ({$message['codetag']})";
                    }
                    $message = $this->t($type) . ' ' . $messagePart;
                }
                if ($format === self::Format_FormattedText) {
                    $message = "* $message\n\n";
                } elseif ($format === self::Format_Html) {
                    $message = "<li>" . nl2br(htmlspecialchars($message, ENT_NOQUOTES)) . "</li>\n";
                }
                $result[] = $message;
            }
            if ($format === self::Format_FormattedText) {
                $result = implode('', $result);
            } elseif ($format === self::Format_Html) {
                $result = "<ul>\n" . implode('', $result) . "</ul>\n";
            }
        }
        return $result;
    }
858498
protected function translateMessages(array $messages)
    {
        $results = array();
        foreach( $messages as $message ) {
            $results[] = Translate::message($message);
        }

        return $results;
    }
1260938
public function createSms($body, $recipients, $sender)
    {
        if (is_array($recipients)) {
            $sms = $this->factory->createSms($body, $recipients, $sender);
        } else {
            $sms = $this->factory->createSms($body, array($recipients), $sender);
        }

        return $sms;
    }