Completed
Push — master ( 055691...1f9c21 )
by Siim
13:14
created

DtoPopulator::populate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 24.01.19
6
 * Time: 8:33
7
 */
8
9
namespace Sf4\Api\Dto;
10
11
use Sf4\Populator\Populator;
12
13
class DtoPopulator
14
{
15
    /**
16
     * @param DtoInterface $dto
17
     * @param array $data
18
     */
19
    public function populate(DtoInterface $dto, array $data)
20
    {
21
        $populator = new Populator();
22
        try {
23
            $populator->populate($data, $dto);
24
        } catch (\ReflectionException $e) {
25
            $dto = new ErrorDto();
26
            $dto->error = $e->getMessage();
27
        }
28
    }
29
}
30