Test Failed
Pull Request — master (#90)
by Maximo
07:11
created

FileMapper::mapToObject()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 25
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 20
nc 2
nop 2
dl 0
loc 25
ccs 0
cts 23
cp 0
crap 6
rs 9.6
c 0
b 0
f 0
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 Canvas\Models\FileSystem;
9
use Canvas\Dto\Files;
10
use Canvas\Models\FileSystemEntities;
11
12
// You can either extend the CustomMapper, or just implement the MapperInterface
13
// directly.
14
class FileMapper extends CustomMapper
15
{
16
    public $systemModuleId;
17
    public $entityId;
18
19
    /**
20
     * @param Canvas\Models\FileSystem $file
0 ignored issues
show
Bug introduced by
The type Canvas\Mapper\Canvas\Models\FileSystem was not found. Did you mean Canvas\Models\FileSystem? If so, make sure to prefix the type with \.
Loading history...
21
     * @param Canvas\Dto\Files $fileDto
0 ignored issues
show
Bug introduced by
The type Canvas\Mapper\Canvas\Dto\Files was not found. Did you mean Canvas\Dto\Files? If so, make sure to prefix the type with \.
Loading history...
22
     * @return Files
23
     */
24
    public function mapToObject($file, $fileDto)
25
    {
26
        $fieledName = FileSystemEntities::findFirst([
27
            'conditions' => 'system_modules_id = ?0 AND entity_id = ?1 AND filesystem_id = ?2',
28
            'bind' => [$this->systemModuleId, $this->entityId , $file->getId()]
29
        ]);
30
31
        $fileDto->id = $file->getId();
32
        $fileDto->companies_id = $file->companies_id;
33
        $fileDto->apps_id = $file->apps_id;
34
        $fileDto->users_id = $file->users_id;
35
        $fileDto->system_modules_id = $this->systemModuleId;
36
        $fileDto->entity_id = $this->entityId;
37
        $fileDto->name = $file->name;
38
        $fileDto->field_name = $fieledName ? $fieledName->field_name : null;
39
        $fileDto->path = $file->path;
40
        $fileDto->url = $file->url;
41
        $fileDto->size = $file->size;
42
        $fileDto->file_type = $file->file_type;
43
        $fileDto->created_at = $file->created_at;
44
        $fileDto->updated_at = $file->updated_at;
45
        $fileDto->is_deleted = $file->is_deleted;
46
        $fileDto->attributes = $file->getAllSettings();
47
48
        return $fileDto;
49
    }
50
}
51