ListSchemaMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 12
c 0
b 0
f 0
dl 0
loc 41
ccs 0
cts 17
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A mapToObject() 0 29 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Mapper;
6
7
use AutoMapperPlus\CustomMapper\CustomMapper;
0 ignored issues
show
Bug introduced by
The type AutoMapperPlus\CustomMapper\CustomMapper 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...
8
use Baka\Elasticsearch\Contracts\CustomFiltersSchemaTrait;
0 ignored issues
show
Bug introduced by
The type Baka\Elasticsearch\Contr...ustomFiltersSchemaTrait 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...
9
10
// You can either extend the CustomMapper, or just implement the MapperInterface
11
// directly.
12
class ListSchemaMapper extends CustomMapper
13
{
14
    use CustomFiltersSchemaTrait;
15
16
    private $elastic;
0 ignored issues
show
introduced by
The private property $elastic is not used, and could be removed.
Loading history...
17
18
    /**
19
     * @param SystemModules $systeModel
0 ignored issues
show
Bug introduced by
The type Canvas\Mapper\SystemModules 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...
20
     * @param \Canvas\Dto\ListSchema $listSchema
21
     *
22
     * @return ListSchema
23
     */
24
    public function mapToObject($systeModel, $listSchema, array $context = [])
25
    {
26
        $listSchema->bulkActions = [
27
            [
28
                'name' => 'Export CSV',
29
                'action' => 'exportCsv'
30
            ], [
31
                'name' => 'Export PDF',
32
                'action' => 'exportPdf'
33
            ], [
34
                'name' => 'Delete',
35
                'action' => 'bulkDelete'
36
            ]
37
        ];
38
39
        //if the system model uses elastic then we can show custom filters
40
        /*         if ($systeModel->useElastic()) {
41
                    $this->elastic = DI::getDefault()->get('elastic');
42
                    $listSchema->customFilterFields = $this->getSchema($systeModel->slug);
43
                }
44
         */
45
        /**
46
         * get the schema.
47
         *
48
         * @todo in PHP 7.3 change to use exceptions
49
         */
50
        $listSchema->tableFields = !empty($systeModel->browse_fields) ? json_decode($systeModel->browse_fields) : null;
51
52
        return $listSchema;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $listSchema returns the type Canvas\Dto\ListSchema which is incompatible with the documented return type Canvas\Mapper\ListSchema.
Loading history...
53
    }
54
}
55