Сохраняет группу
Создаст если не было, обновит если существует и отличается
@param $code
@param array $fields , обязательные параметры - название групы
@return bool|int|mixed
@throws \Sprint\Migration\Exceptions\HelperException
514534
public function saveGroup($code, $fields = array()) {
        $fields['STRING_ID'] = $code;
        $this->checkRequiredKeys(__METHOD__, $fields, array('STRING_ID', 'NAME'));

        $exists = $this->getGroup($fields['STRING_ID']);
        $exportExists = $this->prepareExportGroup($exists);
        $fields = $this->prepareExportGroup($fields);

        if (empty($exists)) {
            $ok = $this->getMode('test') ? true : $this->addGroup($fields['STRING_ID'], $fields);
            $this->outNoticeIf($ok, 'Группа %s: добавлена', $fields['NAME']);
            return $ok;
        }

        if ($this->hasDiff($exportExists, $fields)) {
            $ok = $this->getMode('test') ? true : $this->updateGroup($exists['ID'], $fields);
            $this->outNoticeIf($ok, 'Группа %s: обновлена', $fields['NAME']);
            $this->outDiffIf($ok, $exportExists, $fields);
            return $ok;
        }


        $ok = $this->getMode('test') ? true : $exists['ID'];
        if ($this->getMode('out_equal')) {
            $this->outIf($ok, 'Группа %s: совпадает', $fields['NAME']);
        }
        return $ok;
    }
316479
public function tokenize($code)
    {
        $this->tokens = array();
        $lines        = preg_split('/\r?\n/', $code);
        $number       = 0;

        foreach ($lines as $number => $fragment) {
            $this->processLine($number + 1, $fragment);
            $this->tokens[] = new Token(self::TOKEN_EOL, null, $number + 1);
        }
        $this->tokens[] = new Token(self::TOKEN_EOF, null, $number + 1);

        return new TokenStream($this->tokens);
    }
1165822
public function getTransactionsByCode($code)
    {
        $this->_library->setEnvironment();
        $this->_library->setCharset();
        $this->_library->setLog();

        $response = null;
        try {
            $response = \PagSeguro\Services\Transactions\Search\Code::search(
                $this->_library->getPagSeguroCredentials(),
                $code
            );

            return $response;
        } catch (Exception $e) {
            throw new Exception($e->getMessage());
        }
    }
545103
public static function filterStatusCode(int $code): int
    {
        $filteredCode = \filter_var($code, \FILTER_VALIDATE_INT, ['options' => [
            'min_range' => self::MINIMUM,
            'max_range' => self::MAXIMUM,
        ]]);

        if ($filteredCode === false) {
            throw new InvalidArgumentException(\sprintf(
                'The submitted code "%s" must be a positive integer between %s and %s.',
                $code,
                self::MINIMUM,
                self::MAXIMUM
            ));
        }

        return $code;
    }
660497
protected function filterStatusCode($code)
    {
        $code = filter_var($code, FILTER_VALIDATE_INT, ['options' => [
            'min_range' => self::MINIMUM,
            'max_range' => self::MAXIMUM,
        ]]);
        if (!$code) {
            throw new InvalidArgumentException(
                'The submitted code must be a positive integer between '.self::MINIMUM.' and '.self::MAXIMUM
            );
        }

        return $code;
    }
312021
public function GetDescendantCountByCode($Code) {
      $Category = $this->GetByCode($Code);
      if ($Category)
         return round(($Category->TreeRight - $Category->TreeLeft - 1) / 2);

      return 0;
   }
674705
protected function getMessageByCode($code)
    {
        $t = \Cetera\Application::getInstance()->getTranslator();
        switch ($code) {
            case self::SERVER_LIMIT:            return $t->_('Исчерпан лимит на количество серверов в системе');
            case self::INVALID_PARAMS:          return $t->_('Неверный параметр');
            case self::CAT_EXISTS:              return $t->_('Раздел уже существует "%s"');
            case self::CAT_PHYSICAL_EXISTS:     return $t->_('Существует файл или каталог с таким именем');
            case self::MATERIAL_NOT_FOUND:      return $t->_('Материал не найден');
            case self::USER_NOT_FOUND:          return $t->_('Пользователь не найден');
            case self::INVALID_PASSWORD:        return $t->_('Неправильный пароль');
            case self::AUTHORIZATION_FAILED:    return $t->_('Вы не опознаны');
            case self::INVALID_EMAIL:           return $t->_('Неправильный E-mail');
            case self::SQL:                     return $t->_('Ошибка SQL: %s');
            case self::USER_EXISTS:             return $t->_('Такой пользователь уже существует');
            case self::PASSWORDS_DOESNT_MATCH:  return $t->_('-');
            case self::SERVER_NOT_FOUND:        return $t->_('-');
            case self::TYPE_EXISTS:             return $t->_('-');
            case self::EMAIL_EXISTS:            return $t->_('Такой E-mail уже существует');
            case self::CANT_CREATE:             return $t->_('Невозможно содать тему обсуждения');
            case self::MESSAGE_EXISTS:          return $t->_('Сообщение уже существует');
            case self::NO_RIGHTS:               return $t->_('Недостаточно полномочий для совершения этого действия');
            case self::TYPE_RESERVED:           return $t->_('-');
            case self::TYPE_FIXED:              return $t->_('-');
            case self::FIELD_EXISTS:            return $t->_('Поле c таким Alias уже существует');
            case self::FIELD_NOT_FOUND:         return $t->_('Поле "%s" обязательно для заполнения');
            case self::CAT_NOT_FOUND:           return $t->_('Раздел не найден');
            case self::ALIAS_EXISTS:            return $t->_('Материал с таким alias уже существует');
            case self::ADD_FIELD:               return $t->_('-');
            case self::EDIT_FIELD:              return $t->_('-');
            case self::ENUM_FIELD:              return $t->_('-');
            case self::FIELD_REQUIRED:          return $t->_('-');
            case self::CHOOSE_CATALOG:          return $t->_('-');
            case self::FILE_NOT_FOUND:          return $t->_('Файл не найден: %s');
            case self::MATERIALS_LIMIT:         return $t->_('Вы превысили лимит на количество материалов');
            case self::UNKNOWN:
            default:                            return $t->_('Неизвестная ошибка (%s)');
        }
    }
1239492
public function sendError($code = 204, $vars = null, $headers = [])
    {
        $languageKey = $code . '_' . error_code_string($code);

        $error = [
            'code'    => $code,
            'title'   => language()->getLine($languageKey . '_TITLE'),
            'message' => language()->getLine($languageKey . '_MESSAGE'),
        ];

        $this->statusCode = $code;
        $this->reasonPhrase = $error[ 'title' ];

        if (is_string($vars)) {
            $vars = ['message' => $vars];
        } elseif (is_array($vars) and empty($vars[ 'message' ])) {
            $vars[ 'message' ] = $error[ 'message' ];
        }

        if (isset($vars[ 'message' ])) {
            $error[ 'message' ] = $vars[ 'message' ];
        }

        if (is_ajax() or $this->mimeType !== 'text/html') {
            $this->statusCode = $code;
            $this->reasonPhrase = $error[ 'title' ];
            $this->send($vars);

            exit(EXIT_ERROR);
        }

        $this->sendHeaders($headers);

        extract($error);

        ob_start();
        include $this->getFilePath('error-code');
        $htmlOutput = ob_get_contents();
        ob_end_clean();

        echo $htmlOutput;
        exit(EXIT_ERROR);
    }
324234
public final function setStatusCode($code)
    {
        if (! is_numeric($code)) {

            throw new ehough_shortstop_api_exception_InvalidArgumentException(
                'Status code must be an integer (' . $code . ')'
            );
        }

        $code = intval($code);

        if ($code < 100 || $code > 599) {

            throw new ehough_shortstop_api_exception_InvalidArgumentException(
                'Status code must be in the range of 100 - 599'
            );
        }

        $this->_statusCode = $code;
    }
438789
public function getNthSubfield ($code, $n) 
    {
        $count = 0;
        foreach ($this->getSubfields() as $subfield) {
            if ($subfield->getCode() == $code) {
                if ($count == $n) {
                    return $subfield;
                }
                $count++;
            }
        }
        return null;
    }
708073
public static function errorToException($code){
    if(!isset(self::$codeMap[$code])){
      return new BadResponseException(sprintf(
        'Undefined error code "%s"',
        $code
      ));
    }
    $exceptionClass = self::$codeMap[$code];
    return  new $exceptionClass;
  }
1124881
protected function validateCode($code)
    {
        if (is_integer($code)) {
            return true;
        }

        // Plug it back in and see what we get
        if (is_string($code)) {
            return $this->set($code);
        }

        if (is_array($code)) {
            return $this->validateCodeArray($code);
        }

        return false;
    }
198833
public function getChildrenColumnNumber($code)
    {
        if (in_array($code, $this->matchingChild))
        {
            foreach ($this->matchingChild as $number => $codeValue)
            {
                if ($codeValue == $code)
                {
                    return (int) $number;
                }
            }
        }

        return null;
    }
1331864
public static function isValidCode($code)
    {
        if (array_key_exists($code, self::getInfoForCurrencies())) {
            return true;
        } elseif (array_key_exists($code, self::getInfoForCurrenciesWithoutCurrencyCode())) {
            return true;
        } elseif (array_key_exists($code, self::getInfoForCurrenciesWithUnofficialCode())) {
            return true;
        } elseif (array_key_exists($code, self::getInfoForCurrenciesWithHistoricalCode())) {
            return true;
        } else {
            return false;
        }
    }
54462
protected function findFileObject($code)
    {
        if (!$code) {
            throw new ApplicationException('Missing code');
        }

        $parts = explode('!', base64_decode($code));
        if (count($parts) < 2) {
            throw new ApplicationException('Invalid code');
        }

        list($id, $hash) = $parts;

        if (!$file = FileModel::find((int) $id)) {
            throw new ApplicationException('Unable to find file');
        }

        /**
         * Ensure that the file model utilized for this request is
         * the one specified in the relationship configuration
         */
        if ($file->attachment) {
            $fileModel = $file->attachment->{$file->field}()->getRelated();

            /**
             * Only attempt to get file model through its assigned class
             * when the assigned class differs from the default one that
             * the file has already been loaded from
             */
            if (get_class($file) !== get_class($fileModel)) {
                $file = $fileModel->find($file->id);
            }
        }

        $verifyCode = self::getUniqueCode($file);
        if ($code != $verifyCode) {
            throw new ApplicationException('Invalid hash');
        }

        return $file;
    }
392489
public function attemptMobileChange($code)
    {
        /** @var Token $token */
        $token = Token::find()->where([
            'user_id' => $this->id,
            'code' => $code
        ])->andWhere(['in', 'type', [Token::TYPE_CONFIRM_NEW_MOBILE, Token::TYPE_CONFIRM_OLD_MOBILE]])->one();
        if (empty($this->unconfirmed_mobile) || $token === null || $token->isExpired) {
            Yii::$app->session->setFlash('danger', Yii::t('user', 'Your confirmation token is invalid or expired'));
        } else {
            $token->delete();
            if (empty($this->unconfirmed_mobile)) {
                Yii::$app->session->setFlash('danger', Yii::t('user', 'An error occurred processing your request'));
            } elseif (static::find()->where(['mobile' => $this->unconfirmed_mobile])->exists() == false) {
                if ($this->getSetting('mobileChangeStrategy') == Settings::STRATEGY_SECURE) {
                    switch ($token->type) {
                        case Token::TYPE_CONFIRM_NEW_MOBILE:
                            $this->flags |= self::NEW_MOBILE_CONFIRMED;
                            Yii::$app->session->setFlash('success', Yii::t('user', 'Awesome, almost there. Now you need to input the confirmation code sent to your old mobile'));
                            break;
                        case Token::TYPE_CONFIRM_OLD_MOBILE:
                            $this->flags |= self::OLD_MOBILE_CONFIRMED;
                            Yii::$app->session->setFlash('success', Yii::t('user', 'Awesome, almost there. Now you need to input the confirmation code sent to your new mobile'));
                            break;
                    }
                }
                if ($this->getSetting('mobileChangeStrategy') == Settings::STRATEGY_DEFAULT
                    || ($this->flags & self::NEW_MOBILE_CONFIRMED && $this->flags & self::OLD_MOBILE_CONFIRMED)) {
                    $this->mobile = $this->unconfirmed_mobile;
                    $this->unconfirmed_mobile = null;
                    Yii::$app->session->setFlash('success', Yii::t('user', 'Your mobile address has been changed'));
                }
                $this->save(false);
            }
        }
    }
238254
private function getAccessTokenFields($code)
    {
        $this->oAuthFields = [
            'grant_type' => 'authorization_code',
            'code' => $code,
            'redirect_uri' => $this->mpRedirectURL,
            'client_id' => $this->mpClientId,
            'client_secret' => $this->mpClientSecret,
        ];

        $this->fieldCount = count($this->oAuthFields);

        return $this->oAuthFields;
    }