Blame view

vendor/alibabacloud/client/src/Accept.php 914 Bytes
0c34aba8   xu   更新阿里云短信接口
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

namespace AlibabaCloud\Client;

/**
 * Class Accept
 *
 * @package AlibabaCloud\Client
 */
class Accept
{
    /**
     * @var string
     */
    private $format;

    /**
     * Accept constructor.
     *
     * @param string $format
     */
    private function __construct($format)
    {
        $this->format = $format;
    }

    /**
     * @param $format
     *
     * @return Accept
     */
    public static function create($format)
    {
        return new static($format);
    }

    /**
     * @return mixed|string
     */
    public function toString()
    {
        $key = \strtoupper($this->format);

        $list = [
            'JSON' => 'application/json',
            'XML'  => 'application/xml',
            'RAW'  => 'application/octet-stream',
            'FORM' => 'application/x-www-form-urlencoded'
        ];

        return isset($list[$key]) ? $list[$key] : $list['RAW'];
    }
}