GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#134)
by Yong
04:07
created

Format   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 40
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A toString() 0 10 2
A __construct() 0 3 1
1
<?php
2
3
namespace AlibabaCloud\Client;
4
5
/**
6
 * Class Format
7
 *
8
 * @package AlibabaCloud\Client
9
 */
10
class Format
11
{
12
    /**
13
     * @var string
14
     */
15
    private $format;
16
17
    /**
18
     * Format constructor.
19
     *
20
     * @param string $format
21
     */
22 21
    private function __construct($format)
23
    {
24 21
        $this->format = $format;
25 21
    }
26
27
    /**
28
     * @param $format
29
     *
30
     * @return Format
31
     */
32 21
    public static function create($format)
33
    {
34 21
        return new static($format);
35
    }
36
37
    /**
38
     * @return mixed|string
39
     */
40 21
    public function toString()
41
    {
42 21
        $key = \strtoupper($this->format);
43
44
        $list = [
45 21
            'JSON' => 'application/json',
46
            'XML'  => 'application/xml'
47 21
        ];
48
49 21
        return isset($list[$key]) ? $list[$key] : 'application/octet-stream';
50
    }
51
}
52