Completed
Push — master ( 188ba1...86d637 )
by Samuel
02:55
created

PostInput   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 7
ccs 0
cts 2
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getData() 0 4 1
1
<?php
2
3
namespace Kelemen\ApiNette\Validator\Input;
4
5
class PostInput implements InputInterface
6
{
7
    public function getData()
0 ignored issues
show
Coding Style introduced by
getData uses the super-global variable $_POST 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...
8
    {
9
        return $_POST;
10
    }
11
}
12