121 public function setField(
string $fieldName,
string $value): self
123 $this->fields[$fieldName] = $value;
130 $this->fields = array_merge($this->fields,
$fields);
137 $this->fields[static::FIELD_NAME] = $name;
144 $this->fields[static::FIELD_PERSONAL_ACCOUNT] = $personalAccount;
151 $this->fields[static::FIELD_BANK_NAME] = $bankName;
156 public function setBIC(
string $bic): self
158 $this->fields[static::FIELD_BIC] = $bic;
165 $this->fields[static::FIELD_CORRESPONDENT_ACCOUNT] = $correspondentAccount;
175 foreach ($mandatoryFieldNames as $mandatoryFieldName)
177 if (empty($this->fields[$mandatoryFieldName]))
181 'Mandatory field ' . $mandatoryFieldName .
' is not filled',
182 static::ERROR_CODE_MANDATORY_FIELD_IS_NOT_FILLED,
187 foreach ($this->fields as $fieldName => $value)
193 'Incorrect value type ' . $fieldName,
194 static::ERROR_CODE_VALUE_INCORRECT_TYPE,
199 $value = (string)$value;
202 if ($maxFieldLength > 0 && mb_strlen($value) > $maxFieldLength)
206 'The value of ' . $fieldName .
' is too long',
207 static::ERROR_CODE_VALUE_IS_TOO_LONG,
218 return (is_null($value) || is_string($value) || is_int($value) || is_float($value));
225 static::FIELD_PERSONAL_ACCOUNT,
226 static::FIELD_BANK_NAME,
228 static::FIELD_CORRESPONDENT_ACCOUNT,
234 static $maximumFieldLengths = [
235 self::FIELD_NAME => 160,
236 self::FIELD_PERSONAL_ACCOUNT => 20,
237 self::FIELD_BANK_NAME => 120,
238 self::FIELD_BIC => 9,
239 self::FIELD_CORRESPONDENT_ACCOUNT => 20,
242 return $maximumFieldLengths[$fieldName] ??
null;
250 $decodedFields = array_filter($decodedFields,
static function($value) {
251 return (!empty($value) && !is_array($value) && !is_object($value));
255 static::FORMAT_IDENTIFIER
256 . static::FORMAT_VERSION
262 $data .= $delimiter . $fieldName . static::VALUE_DELIMITER . ($decodedFields[$fieldName] ??
'');
263 unset ($decodedFields[$fieldName]);
266 foreach ($decodedFields as $fieldName => $value)
268 $data .= $delimiter . $fieldName . static::VALUE_DELIMITER . $value;
276 $possibleDelimiters = [
'|',
'~',
'_',
'#',
'$' ,
'^',
'&',
'*',
'/',
'`',
'@',
'%'];
278 $allValues = implode(
' ', $this->fields);
279 foreach ($possibleDelimiters as $delimiter)
281 if (mb_strpos($allValues, $delimiter) ===
false)
292 if ($this->charsetCode === static::CHARSET_WIN1251)
294 return 'Windows-1251';
296 if ($this->charsetCode === static::CHARSET_KOI8R)
301 $this->charsetCode = static::CHARSET_UTF8;
310 return Encoding::convertEncoding($this->fields, SITE_CHARSET, $charsetTo);
const FIELD_PAYMENT_REASON_CODE
const FIELD_DOCUMENT_DATE
setCharsetCode(int $charsetCode)
const FIELD_COUNTER_VALUE
const FIELD_RULING_NUMBER
setField(string $fieldName, string $value)
setCorrespondentAccount(string $correspondentAccount)
const FIELD_PAYER_ADDRESS
const ERROR_CODE_MANDATORY_FIELD_IS_NOT_FILLED
const FIELD_REGISTRATION_PAYMENT_TYPE
const FIELD_PAYMENT_CATEGORY
const FIELD_CHILD_FULL_NAME
const ERROR_CODE_VALUE_IS_TOO_LONG
const FIELD_PAYMENT_PERIOD
const FIELD_PENSION_ACCOUNT
const FIELD_NOTICE_NUMBER
const FIELD_BUDGET_PERSONAL_ACCOUNT
const FIELD_DOCUMENT_INDEX
const FIELD_PAYER_ID_TYPE
const FIELD_INSTITUTE_NUMBER
setPersonalAccount(string $personalAccount)
setBankName(string $bankName)
getFieldValueMaximumLength(string $fieldName)
const FIELD_TAX_PAYMENT_KIND_CODE
const FIELD_PAYER_PERSONAL_ACCOUNT
const FIELD_PERSONAL_ACCOUNT
const FIELD_SPECIALIST_FULL_NAME
const FIELD_DRAWER_STATUS_CODE
const FIELD_PROCEEDING_NUMBER
const FIELD_DOCUMENT_NUMBER
const FIELD_CORRESPONDENT_ACCOUNT
const ERROR_CODE_VALUE_INCORRECT_TYPE
const FIELD_PAYER_ID_NUMBER