format; }, ''); $args = array_map(function (self $field) { switch ($field->format) { case 'V': if ($field->value > self::MAX_V) { throw new RuntimeException(print_r($field->value, true) . ' is larger than 32 bits'); } break; case 'v': if ($field->value > self::MAX_v) { throw new RuntimeException(print_r($field->value, true) . ' is larger than 16 bits'); } break; case 'P': break; default: break; } return $field->value; }, $fields); return pack($fmt, ...$args); } }