Passed
Push — master ( e5acb2...2b13b1 )
by Evgeny
07:45
created

FormParser::getParams()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.1406

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 4
nop 0
dl 0
loc 12
ccs 6
cts 8
cp 0.75
crap 3.1406
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
4
 *
5
 * Licensed under The MIT License
6
 * Redistributions of files must retain the above copyright notice.
7
 *
8
 * @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com)
9
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
10
 */
11
12
namespace CakeDC\Api\Service\RequestParser;
13
14
/**
15
 * Parse form based data representation.
16
 */
17
class FormParser extends BaseParser
18
{
19
20
    /**
21
     * Resolves the request params as a key => value array.
22
     *
23
     * @return array
24
     */
25 66
    public function getParams()
26
    {
27 66
        $request = $this->_service->getRequest();
28 66
        if ($request == null) {
29
            stackTrace();
30
        }
31 66
        if ($request->is(['post', 'put'])) {
32 33
            return $request->getData();
0 ignored issues
show
Bug Compatibility introduced by
The expression $request->getData(); of type null|string|array adds the type string to the return on line 32 which is incompatible with the return type declared by the abstract method CakeDC\Api\Service\Reque...r\BaseParser::getParams of type array.
Loading history...
33
        }
34
35 33
        return $request->getQuery();
0 ignored issues
show
Bug Compatibility introduced by
The expression $request->getQuery(); of type null|string|array adds the type string to the return on line 35 which is incompatible with the return type declared by the abstract method CakeDC\Api\Service\Reque...r\BaseParser::getParams of type array.
Loading history...
36
    }
37
38
    /**
39
     * Processes the HTTP request.
40
     *
41
     * @return bool
42
     */
43
    public function request()
44
    {
45
        return true;
46
    }
47
}
48