CompletePurchaseRequest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 29
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 4 1
A send() 0 4 1
A sendData() 0 4 1
1
<?php
2
/**
3
 * w-vision
4
 *
5
 * LICENSE
6
 *
7
 * This source file is subject to the MIT License
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that are distributed with this source code.
10
 *
11
 * @copyright  Copyright (c) 2016 Woche-Pass AG (http://www.w-vision.ch)
12
 * @license    MIT License
13
 */
14
15
namespace Omnipay\Datatrans\Message;
16
17
class CompletePurchaseRequest extends AbstractRequest
18
{
19
    /**
20
     * @return array
21
     */
22 3
    public function getData()
0 ignored issues
show
Coding Style introduced by
getData uses the super-global variable $_REQUEST which is generally not recommended.

Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable:

// Bad
class Router
{
    public function generate($path)
    {
        return $_SERVER['HOST'].$path;
    }
}

// Better
class Router
{
    private $host;

    public function __construct($host)
    {
        $this->host = $host;
    }

    public function generate($path)
    {
        return $this->host.$path;
    }
}

class Controller
{
    public function myAction(Request $request)
    {
        // Instead of
        $page = isset($_GET['page']) ? intval($_GET['page']) : 1;

        // Better (assuming you use the Symfony2 request)
        $page = $request->query->get('page', 1);
    }
}
Loading history...
23
    {
24 3
        return $_REQUEST;
25
    }
26
27
    /**
28
     * @return ResponseInterface
29
     */
30 3
    public function send()
31
    {
32 3
        return $this->sendData($this->getData());
33
    }
34
35
    /**
36
     * Send the request with specified data
37
     *
38
     * @param  mixed $data The data to send
39
     * @return ResponseInterface
40
     */
41 3
    public function sendData($data)
42
    {
43 3
        return $this->response = new CompletePurchaseResponse($this, $data);
44
    }
45
}
46