Completed
Push — master ( e5a757...47ec18 )
by Robbie
14s
created

FormEncodedDataFormatter::supportedExtensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace SilverStripe\RestfulServer\DataFormatter;
4
5
/**
6
 * Accepts form encoded strings and converts them
7
 * to a valid PHP array via {@link parse_str()}.
8
 *
9
 * Example when using cURL on commandline:
10
 * <code>
11
 * curl -d "Name=This is a new record" http://host/api/v1/(DataObject)
12
 * curl -X PUT -d "Name=This is an updated record" http://host/api/v1/(DataObject)/1
13
 * </code>
14
 *
15
 * @todo Format response form encoded as well - currently uses XMLDataFormatter
16
 *
17
 * @author Cam Spiers <camspiers at gmail dot com>
18
 */
19
class FormEncodedDataFormatter extends XMLDataFormatter
20
{
21
22
    public function supportedExtensions()
23
    {
24
        return array(
25
        );
26
    }
27
28
    public function supportedMimeTypes()
29
    {
30
        return array(
31
            'application/x-www-form-urlencoded'
32
        );
33
    }
34
35
    public function convertStringToArray($strData)
36
    {
37
        $postArray = array();
38
        parse_str($strData, $postArray);
39
        return $postArray;
40
        //TODO: It would be nice to implement this function in Convert.php
41
        //return Convert::querystr2array($strData);
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
42
    }
43
}
44