Test Failed
Branch add-core-tests (a060d8)
by Rafael
05:48
created

FileMapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Mapper;
6
7
use AutoMapperPlus\CustomMapper\CustomMapper;
8
use Canvas\Dto\Files;
9
use Canvas\Models\FileSystemEntities;
10
11
// You can either extend the CustomMapper, or just implement the MapperInterface
12
// directly.
13
class FileMapper extends CustomMapper
14
{
15
    public $systemModuleId;
16
    public $entityId;
17
18
    /**
19
     * constructor.
20
     *
21
     * @param integer $entityId
22
     * @param integer $systemModuleId
23
     */
24 1
    public function __construct(int $entityId, int $systemModuleId)
25
    {
26 1
        $this->systemModuleId = $systemModuleId;
27 1
        $this->entityId = $entityId;
28 1
    }
29
30
    /**
31
     * @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...
32
     * @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...
33
     * @return Files
34
     */
35 1
    public function mapToObject($fileEntity, $fileDto, array $context = [])
36
    {
37 1
        $fileDto->id = $fileEntity->getId();
38 1
        $fileDto->filesystem_id = $fileEntity->filesystem_id;
39 1
        $fileDto->name = $fileEntity->file->name;
40 1
        $fileDto->field_name = $fileEntity->field_name;
41 1
        $fileDto->url = $fileEntity->file->url;
42 1
        $fileDto->size = $fileEntity->file->size;
43 1
        $fileDto->file_type = $fileEntity->file->file_type;
44 1
        $fileDto->attributes = $fileEntity->file->getAllSettings();
45
46 1
        return $fileDto;
47
    }
48
}
49