-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathAccept.php
53 lines (46 loc) · 914 Bytes
/
Accept.php
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'];
}
}