Grid::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
nc 1
nop 0
dl 0
loc 18
c 1
b 0
f 0
cc 1
rs 9.8333
1
<?php
2
3
/**
4
 * @namespace
5
 */
6
7
namespace Application\Payments;
8
9
use Application\Wallets\Table;
0 ignored issues
show
Bug introduced by
The type Application\Wallets\Table was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
This use statement conflicts with another class in this namespace, Application\Payments\Table. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
10
use Bluz\Grid\Source\SelectSource;
0 ignored issues
show
Bug introduced by
The type Bluz\Grid\Source\SelectSource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
/**
13
 * Grid based on Table
14
 *
15
 * @package  Application\Payments
16
 *
17
 * @author   dev
18
 * @created  2017-11-02 11:38:54
19
 */
20
class Grid extends \Bluz\Grid\Grid
0 ignored issues
show
Bug introduced by
The type Bluz\Grid\Grid was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $uid = 'payments';
26
27
    /**
28
     * @return void
29
     * @throws \Bluz\Grid\GridException
30
     */
31
    public function init(): void
32
    {
33
        // Current table as source of grid
34
        $adapter = new SelectSource();
35
        $adapter->setSource(Table::select());
36
        $adapter->setSource(
37
            Table::select()
38
                ->addSelect('users.login as login')
39
                ->join('payments', 'transactions', 'transactions', 'transactions.id = payments.transactionId')
40
                ->join('transactions', 'users', 'users', 'users.id = transactions.userId')
41
        );
42
43
        $this->addAlias('users.id', 'user');
44
        $this->addAlias('users.login', 'login');
45
        $this->setAdapter($adapter);
46
        $this->setDefaultLimit(25);
47
        $this->setAllowFilters(['amount', 'currency', 'provider', 'users.id', 'users.login', 'created']);
48
        $this->setAllowOrders(['id', 'amount', 'currency', 'provider', 'users.id', 'users.login', 'created']);
49
    }
50
}
51