Completed
Push — master ( 4c78b7...7d76a2 )
by diego
04:44
created

DatabaseService::getDatabaseConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * DatabaseService.php
4
 */
5
6
namespace HDNET\Importr\Service;
7
8
/**
9
 * DatabaseService
10
 */
11
class DatabaseService
12
{
13
    /**
14
     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
15
     */
16
    public function getDatabaseConnection()
0 ignored issues
show
Coding Style introduced by Tim Spiekerkötter
getDatabaseConnection uses the super-global variable $GLOBALS 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...
17
    {
18
        return $GLOBALS['TYPO3_DB'];
19
    }
20
}
21