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

Classes/Service/DatabaseService.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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