Translator from php types to swagger types
@param string $format

@return array
432204
public static function translateSwaggerFormats($format)
    {
        switch (strtolower(preg_replace('/\\\\/im', '', $format))) {
            case 'bool':
            case 'boolean':
                $swaggerType = 'boolean';
                $swaggerFormat = '';
                break;
            default:
            case 'string':
            case 'varchar':
                $swaggerType = 'string';
                $swaggerFormat = '';
                break;
            case 'binary':
            case 'varbinary':
                $swaggerType = 'string';
                $swaggerFormat = 'password';
                break;
            case 'int':
            case 'integer':
                $swaggerType = 'integer';
                $swaggerFormat = 'int32';
                break;
            case 'float':
            case 'double':
                $swaggerType = 'number';
                $swaggerFormat = strtolower($format);
                break;
            case 'date':
                $swaggerType = 'string';
                $swaggerFormat = 'date';
                break;
            case 'timestamp':
            case 'datetime':
                $swaggerType = 'string';
                $swaggerFormat = 'date-time';
                break;

        }
        return [$swaggerType, $swaggerFormat];
    }
1094954
public function toString(string $format = null) : string
    {
        $operations = $this->operations;
        $operations[] = [ 'getImage', [ $format ] ];
        
        $driver = $this->getDriver();
        return array_reduce($operations, function ($carry, $item) use ($driver) {
            return $driver->{$item[0]}(...$item[1]);
        });
    }
782668
protected function parse_format($format) {
		$format = parent::parse_format($format);
		return str_replace(array_keys(static::$months), static::$months, $format);
	}
1072826
public function get($format)
    {
        if ('plain' == $format || 'string' == $format) {
            return $this->makePlain();
        }
        if ('json' == $format) {
            return $this->makeJson();
        }

        return json_decode($this->response, true);
    }
1201178
public function getFormatImagineSaveOptions($format)
    {
        $format = $this->normalizeFormat($format);
        $result = [
            'format' => $format,
        ];
        switch ($format) {
            case static::FORMAT_PNG:
                $result['png_compression_level'] = $this->getDefaultPngCompressionLevel();
                break;
            case static::FORMAT_JPEG:
                $result['jpeg_quality'] = $this->getDefaultJpegQuality();
                break;
        }

        return $result;
    }
1296013
protected static function parseFormat($format)
    {
        static::loadFormats();

        // If the format equals a constant's value, just return it.
        if (in_array($format, static::$formats, true)) {
            return $format;
        }

        // Otherwise we'll assume the format is the constant's name.
        return Arr::get(static::$formats, strtoupper($format));
    }
1075115
public function translatedFormat(string $format): string
    {
        $replacements = static::getFormatsToIsoReplacements();
        $context = '';
        $isoFormat = '';
        $length = mb_strlen($format);

        for ($i = 0; $i < $length; $i++) {
            $char = mb_substr($format, $i, 1);

            if ($char === '\\') {
                $replacement = mb_substr($format, $i, 2);
                $isoFormat .= $replacement;
                $i++;

                continue;
            }

            if (!isset($replacements[$char])) {
                $replacement = preg_match('/^[A-Za-z]$/', $char) ? "\\$char" : $char;
                $isoFormat .= $replacement;
                $context .= $replacement;

                continue;
            }

            $replacement = $replacements[$char];

            if ($replacement === true) {
                static $contextReplacements = null;

                if ($contextReplacements === null) {
                    $contextReplacements = [
                        'm' => 'MM',
                        'd' => 'DD',
                        't' => 'D',
                        'j' => 'D',
                        'N' => 'e',
                        'w' => 'e',
                        'n' => 'M',
                        'o' => 'YYYY',
                        'Y' => 'YYYY',
                        'y' => 'YY',
                        'g' => 'h',
                        'G' => 'H',
                        'h' => 'hh',
                        'H' => 'HH',
                        'i' => 'mm',
                        's' => 'ss',
                    ];
                }

                $isoFormat .= '['.$this->rawFormat($char).']';
                $context .= $contextReplacements[$char] ?? ' ';

                continue;
            }

            if ($replacement instanceof Closure) {
                $replacement = '['.$replacement($this).']';
                $isoFormat .= $replacement;
                $context .= $replacement;

                continue;
            }

            $isoFormat .= $replacement;
            $context .= $replacement;
        }

        return $this->isoFormat($isoFormat, $context);
    }
1271774
public static function generateTypes($inputFields)
    {
        if (!empty(self::$swaggerTypes)) {
            return self::$swaggerTypes;
        }

        $fieldTypes = [];

        foreach ($inputFields as $field) {
            $fieldData = self::getFieldType($field->fieldType);
            $fieldType = $fieldData['fieldType'];
            $fieldFormat = $fieldData['fieldFormat'];

            if (!empty($fieldType)) {
                $fieldType = [
                    'name'   => $field->name,
                    'type'   => $fieldType,
                    'format' => $fieldFormat,
                ];

                $fieldType['description'] = (!empty($field->description)) ? $field->description : '';

                $fieldTypes[] = $fieldType;
            }
        }

        self::$swaggerTypes = $fieldTypes;

        return self::$swaggerTypes;
    }
358892
public function getFormatter($format)
    {
        static $defaultFormatters = [
            self::FORMAT_JSON => 'yii\httpclient\JsonFormatter',
            self::FORMAT_URLENCODED => [
                'class' => 'yii\httpclient\UrlEncodedFormatter',
                'encodingType' => PHP_QUERY_RFC1738
            ],
            self::FORMAT_RAW_URLENCODED => [
                'class' => 'yii\httpclient\UrlEncodedFormatter',
                'encodingType' => PHP_QUERY_RFC3986
            ],
            self::FORMAT_XML => 'yii\httpclient\XmlFormatter',
            self::FORMAT_CURL => 'yii\httpclient\CurlFormatter',
        ];

        if (!isset($this->formatters[$format])) {
            if (!isset($defaultFormatters[$format])) {
                throw new InvalidParamException("Unrecognized format '{$format}'");
            }
            $this->formatters[$format] = $defaultFormatters[$format];
        }

        if (!is_object($this->formatters[$format])) {
            $this->formatters[$format] = Yii::createObject($this->formatters[$format]);
        }

        return $this->formatters[$format];
    }
172693
protected function transform($messages, $format)
	{
		$messages = (array) $messages;

		foreach ($messages as $key => &$message)
		{
			$message = str_replace(':message', $message, $format);
		}

		return $messages;
	}
299595
public function setFormat($format) {
        if ($format === null) {
            $format = [];
        } else if ( ! is_array($format)) {
            $format = [$format];
        }

        $this->format = $format;

        return $this;
    }
99794
protected function parse_format($format) {
		$format = parent::parse_format($format);
		return str_replace(array_keys(static::$days), static::$days, $format);
	}
256220
public function getParser($format)
    {
        static $defaultParsers = [
            self::FORMAT_JSON => 'yii\httpclient\JsonParser',
            self::FORMAT_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_RAW_URLENCODED => 'yii\httpclient\UrlEncodedParser',
            self::FORMAT_XML => 'yii\httpclient\XmlParser',
        ];

        if (!isset($this->parsers[$format])) {
            if (!isset($defaultParsers[$format])) {
                throw new InvalidParamException("Unrecognized format '{$format}'");
            }
            $this->parsers[$format] = $defaultParsers[$format];
        }

        if (!is_object($this->parsers[$format])) {
            $this->parsers[$format] = Yii::createObject($this->parsers[$format]);
        }

        return $this->parsers[$format];
    }
839036
final public function format($format)
    {
        if(is_null($this->value)) {
            return null;
        } else {
            return $this->value->format($format);
        }
    }
853585
public function getFormatter(FormatInterface $format)
    {
        switch ($format->getType()) {
            case 'csv':
                if ($format instanceof CsvFormatInterface) {
                    return new CsvFormatter($format);
                } else {
                    throw new InvalidArgumentException(
                        "Format indicates it is csv but does not implement CsvFormatInterface"
                    );
                }

            // fallthrough
            case 'json':
                if ($format instanceof JsonFormatInterface) {
                    return new JsonFormatter($format);
                } else {
                    throw new InvalidArgumentexception(
                        "Format indicates it is json but does not implement JsonFormatInterface"
                    );
                }

            // fallthrough
            default:
                throw new InvalidArgumentException("Supplied format: {$format->getType()} is unknown");
        }
    }
696438
public function get($format)
    {
        switch ($format) {
            case 'json':
                return $this->toJson();
                break;
            case 'serialize':
                return $this->serialize();
                break;
            case 'array':
                return $this->toArray();
                break;
            case 'xml':
                return $this->toXml();
                break;
            default:
                return $this;
        }
    }
942612
public function format($format = null)
    {
        if ($format !== null) {
            $this->format = $format;
        }

        return $this->format;
    }